Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions tooling/lsp/src/requests/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ impl<'a> Visitor for NodeFinder<'a> {
false
}

fn visit_parsed_submodule(&mut self, parsed_sub_module: &ParsedSubModule, span: Span) -> bool {
fn visit_parsed_submodule(&mut self, parsed_sub_module: &ParsedSubModule, _span: Span) -> bool {
// Switch `self.module_id` to the submodule
let previous_module_id = self.module_id;

Expand All @@ -897,7 +897,9 @@ impl<'a> Visitor for NodeFinder<'a> {
let old_auto_import_line = self.auto_import_line;
self.nesting += 1;

if let Some(lsp_location) = to_lsp_location(self.files, self.file, span) {
if let Some(lsp_location) =
to_lsp_location(self.files, self.file, parsed_sub_module.name.span())
{
self.auto_import_line = (lsp_location.range.start.line + 1) as usize;
}

Expand Down
5 changes: 3 additions & 2 deletions tooling/lsp/src/requests/completion/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1395,6 +1395,7 @@ mod completion_tests {
#[test]
async fn test_auto_imports_when_in_nested_module_and_item_is_further_nested() {
let src = r#"
#[something]
mod foo {
mod bar {
pub fn hello_world() {}
Expand Down Expand Up @@ -1422,8 +1423,8 @@ mod completion_tests {
item.additional_text_edits,
Some(vec![TextEdit {
range: Range {
start: Position { line: 2, character: 4 },
end: Position { line: 2, character: 4 },
start: Position { line: 3, character: 4 },
end: Position { line: 3, character: 4 },
},
new_text: "use bar::hello_world;\n\n ".to_string(),
}])
Expand Down