fix: shifted completion cursor

This commit is contained in:
Myriad-Dreamin 2024-03-10 21:32:32 +08:00
parent 1d230f409d
commit e6a1397c20

View file

@ -16,9 +16,7 @@ impl CompletionRequest {
) -> Option<CompletionResponse> {
let doc = doc.as_deref();
let source = get_suitable_source_in_workspace(world, &self.path).ok()?;
let offset = lsp_to_typst::position(self.position, position_encoding, &source)?;
// the typst's cursor is 1-based, so we need to add 1 to the offset
let cursor = offset + 1;
let cursor = lsp_to_typst::position(self.position, position_encoding, &source)?;
let (offset, completions) =
typst_ide::autocomplete(world, doc, &source, cursor, self.explicit)?;