complete_import: prevent panic when the anchor is the completion source range
(fix rebase mess) Please enter the commit message for your changes. Lines starting
This commit is contained in:
parent
9144214958
commit
200032852b
@ -14,12 +14,8 @@ use crate::{
|
||||
generics::GenericParams,
|
||||
expr::{scope::{ExprScopes, ScopeId}, PatId},
|
||||
impl_block::ImplBlock,
|
||||
<<<<<<< HEAD
|
||||
path::Path,
|
||||
Trait
|
||||
=======
|
||||
path::Path, Trait,
|
||||
>>>>>>> complete_import: add new import resolver infrastructure with some hardcoded importable name.
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
|
@ -19,11 +19,7 @@ use ra_syntax::{
|
||||
|
||||
use crate::{
|
||||
HirDatabase, Function, Struct, Enum, Const, Static, Either, DefWithBody, PerNs, Name,
|
||||
<<<<<<< HEAD
|
||||
AsName, Module, HirFileId, Crate, Trait, Resolver, Ty,
|
||||
=======
|
||||
AsName, Module, HirFileId, Crate, Trait, Resolver, ImportResolver,
|
||||
>>>>>>> complete_import: add new import resolver infrastructure with some hardcoded importable name.
|
||||
AsName, Module, HirFileId, Crate, Trait, Resolver, Ty, ImportResolver,
|
||||
expr::{BodySourceMap, scope::{ScopeId, ExprScopes}},
|
||||
ids::LocationCtx,
|
||||
expr, AstId,
|
||||
|
@ -23,13 +23,23 @@ pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) {
|
||||
);
|
||||
builder.finish()
|
||||
};
|
||||
CompletionItem::new(
|
||||
CompletionKind::Reference,
|
||||
ctx.source_range(),
|
||||
build_import_label(&name, &path),
|
||||
)
|
||||
.text_edit(edit)
|
||||
.add_to(acc)
|
||||
|
||||
// Hack: copied this check form conv.rs beacause auto import can produce edits
|
||||
// that invalidate assert in conv_with.
|
||||
if edit
|
||||
.as_atoms()
|
||||
.iter()
|
||||
.filter(|atom| !ctx.source_range().is_subrange(&atom.delete))
|
||||
.all(|atom| ctx.source_range().intersection(&atom.delete).is_none())
|
||||
{
|
||||
CompletionItem::new(
|
||||
CompletionKind::Reference,
|
||||
ctx.source_range(),
|
||||
build_import_label(&name, &path),
|
||||
)
|
||||
.text_edit(edit)
|
||||
.add_to(acc);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user