fix: Fix vis restriction path completions always using the parent module
This commit is contained in:
parent
d6329f2171
commit
2310908df7
|
@ -20,13 +20,14 @@ pub(crate) fn complete_vis(acc: &mut Completions, ctx: &CompletionContext) {
|
|||
|
||||
match qualifier {
|
||||
Some(PathQualifierCtx { resolution, is_super_chain, .. }) => {
|
||||
// Try completing next child module of the path that is still a parent of the current module
|
||||
if let Some(hir::PathResolution::Def(hir::ModuleDef::Module(module))) = resolution {
|
||||
if let Some(current_module) = ctx.module {
|
||||
let next_towards_current = current_module
|
||||
.path_to_root(ctx.db)
|
||||
.into_iter()
|
||||
.take_while(|it| it != module)
|
||||
.next();
|
||||
.last();
|
||||
if let Some(next) = next_towards_current {
|
||||
if let Some(name) = next.name(ctx.db) {
|
||||
cov_mark::hit!(visibility_qualified);
|
||||
|
|
|
@ -55,6 +55,21 @@ mod bar {}
|
|||
);
|
||||
check(
|
||||
r#"
|
||||
mod qux {
|
||||
mod foo {
|
||||
pub(in crate::$0)
|
||||
}
|
||||
mod baz {}
|
||||
}
|
||||
|
||||
mod bar {}
|
||||
"#,
|
||||
expect![[r#"
|
||||
md qux
|
||||
"#]],
|
||||
);
|
||||
check(
|
||||
r#"
|
||||
mod qux {
|
||||
mod foo {
|
||||
pub(in crate::qux::$0)
|
||||
|
|
Loading…
Reference in a new issue