Skip to content

Commit 0057d1e

Browse files
committed
fix completion for super::super::
1 parent 69faf81 commit 0057d1e

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

crates/ra_hir_def/src/path/lower.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,12 @@ pub(super) fn lower_path(mut path: ast::Path, hygiene: &Hygiene) -> Option<Path>
101101
break;
102102
}
103103
ast::PathSegmentKind::SuperKw => {
104-
kind = PathKind::Super(1);
105-
break;
104+
let nested_super_count = if let PathKind::Super(n) = kind {
105+
n
106+
} else {
107+
0
108+
};
109+
kind = PathKind::Super(nested_super_count + 1);
106110
}
107111
}
108112
path = match qualifier(&path) {

crates/ra_ide/src/completion/complete_dot.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,4 +545,43 @@ mod tests {
545545
"###
546546
)
547547
}
548+
549+
#[test]
550+
fn test_super_super_completion() {
551+
assert_debug_snapshot!(
552+
do_ref_completion(
553+
r"
554+
mod a {
555+
const A: usize = 0;
556+
557+
mod b {
558+
const B: usize = 0;
559+
560+
mod c {
561+
use super::super::<|>
562+
}
563+
}
564+
}
565+
",
566+
),
567+
@r###"
568+
[
569+
CompletionItem {
570+
label: "A",
571+
source_range: [217; 217),
572+
delete: [217; 217),
573+
insert: "A",
574+
kind: Const,
575+
},
576+
CompletionItem {
577+
label: "b",
578+
source_range: [217; 217),
579+
delete: [217; 217),
580+
insert: "b",
581+
kind: Module,
582+
},
583+
]
584+
"###
585+
);
586+
}
548587
}

0 commit comments

Comments
 (0)