fix completion for super::super::

This commit is contained in:
Josh Mcguigan 2020-02-29 20:53:01 -08:00
parent 69faf81e0d
commit 0057d1e10d
2 changed files with 45 additions and 2 deletions

View File

@ -101,8 +101,12 @@ pub(super) fn lower_path(mut path: ast::Path, hygiene: &Hygiene) -> Option<Path>
break;
}
ast::PathSegmentKind::SuperKw => {
kind = PathKind::Super(1);
break;
let nested_super_count = if let PathKind::Super(n) = kind {
n
} else {
0
};
kind = PathKind::Super(nested_super_count + 1);
}
}
path = match qualifier(&path) {

View File

@ -545,4 +545,43 @@ mod tests {
"###
)
}
#[test]
fn test_super_super_completion() {
assert_debug_snapshot!(
do_ref_completion(
r"
mod a {
const A: usize = 0;
mod b {
const B: usize = 0;
mod c {
use super::super::<|>
}
}
}
",
),
@r###"
[
CompletionItem {
label: "A",
source_range: [217; 217),
delete: [217; 217),
insert: "A",
kind: Const,
},
CompletionItem {
label: "b",
source_range: [217; 217),
delete: [217; 217),
insert: "b",
kind: Module,
},
]
"###
);
}
}