Skip to content

Commit

Permalink
Merge 18cf81c into 114903d
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite authored Sep 12, 2024
2 parents 114903d + 18cf81c commit f4a4fe1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
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

0 comments on commit f4a4fe1

Please sign in to comment.