Skip to content

Commit 441e4b4

Browse files
committed
perf(lsp): skip import lexing outside strings
1 parent b4727b7 commit 441e4b4

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

crates/lsp/src/import_resolution.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ pub(crate) fn import_path_at(source: &str, cursor: usize) -> Option<ImportPathAt
3939
return None;
4040
}
4141

42+
// Most navigation requests are issued from ordinary code. Avoid lexing the complete prefix
43+
// when the cursor's line cannot contain a string (the lexer remains the source of truth when
44+
// a quote or an escaped line continuation is present).
45+
if !may_complete_string(source, cursor) {
46+
return None;
47+
}
48+
4249
// Import paths are plain strings; code navigation does not need a full-file parse.
4350
plain_string_at(source, cursor)?;
4451
parse_import_path(source, cursor)

0 commit comments

Comments
 (0)