mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Merge #11402
11402: fix: Fix vis restriction path completions always using the parent module r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
commit
6ef6fa019c
2 changed files with 17 additions and 1 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue