Fix import search not discarding rawness

This commit is contained in:
Lukas Wirth 2025-01-20 14:21:37 +01:00
parent 20ff27e2ba
commit a06606c802
8 changed files with 65 additions and 29 deletions

View file

@ -5,7 +5,7 @@ use ide_db::imports::{
insert_use::ImportScope,
};
use itertools::Itertools;
use syntax::{ast, AstNode, SyntaxNode, ToSmolStr, T};
use syntax::{ast, AstNode, SyntaxNode, ToSmolStr};
use crate::{
config::AutoImportExclusionType,
@ -403,10 +403,11 @@ fn import_on_the_fly_method(
fn import_name(ctx: &CompletionContext<'_>) -> String {
let token_kind = ctx.token.kind();
if matches!(token_kind, T![.] | T![::]) {
String::new()
} else {
if token_kind.is_any_identifier() {
ctx.token.to_string()
} else {
String::new()
}
}

View file

@ -423,7 +423,7 @@ fn render_resolution_path(
let name = local_name.display_no_db(ctx.completion.edition).to_smolstr();
let mut item = render_resolution_simple_(ctx, &local_name, import_to_add, resolution);
if local_name.is_escaped(completion.edition) {
if local_name.needs_escape(completion.edition) {
item.insert_text(local_name.display_no_db(completion.edition).to_smolstr());
}
// Add `<>` for generic types