mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-07-23 12:45:04 +00:00
fix: don't panic on bad node range
This commit is contained in:
parent
4abde9de2e
commit
964def25a9
13 changed files with 51 additions and 92 deletions
|
@ -15,15 +15,14 @@ impl CompletionRequest {
|
|||
position_encoding: PositionEncoding,
|
||||
) -> Option<CompletionResponse> {
|
||||
let source = get_suitable_source_in_workspace(world, &self.path).ok()?;
|
||||
let typst_offset =
|
||||
lsp_to_typst::position_to_offset(self.position, position_encoding, &source);
|
||||
let typst_offset = lsp_to_typst::position(self.position, position_encoding, &source)?;
|
||||
|
||||
let (typst_start_offset, completions) =
|
||||
typst_ide::autocomplete(world, doc.as_deref(), &source, typst_offset, self.explicit)?;
|
||||
|
||||
let lsp_start_position =
|
||||
typst_to_lsp::offset_to_position(typst_start_offset, position_encoding, &source);
|
||||
let replace_range = LspRawRange::new(lsp_start_position, self.position);
|
||||
let replace_range = LspRange::new(lsp_start_position, self.position);
|
||||
Some(typst_to_lsp::completions(&completions, replace_range).into())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue