dev: use implicit autocomplete

This commit is contained in:
Myriad-Dreamin 2024-03-11 15:58:07 +08:00
parent 7f662f87a8
commit 8bfbe7706e

View file

@ -18,8 +18,22 @@ impl CompletionRequest {
let source = get_suitable_source_in_workspace(world, &self.path).ok()?;
let cursor = lsp_to_typst::position(self.position, position_encoding, &source)?;
let (offset, completions) =
typst_ide::autocomplete(world, doc, &source, cursor, self.explicit)?;
// Please see <https://github.com/nvarner/typst-lsp/commit/2d66f26fb96ceb8e485f492e5b81e9db25c3e8ec>
//
// FIXME: correctly identify a completion which is triggered
// by explicit action, such as by pressing control and space
// or something similar.
//
// See <https://github.com/microsoft/language-server-protocol/issues/1101>
// > As of LSP 3.16, CompletionTriggerKind takes the value Invoked for
// > both manually invoked (for ex: ctrl + space in VSCode) completions
// > and always on (what the spec refers to as 24/7 completions).
//
// Hence, we cannot distinguish between the two cases. Conservatively, we
// assume that the completion is not explicit.
let explicit = false;
let (offset, completions) = typst_ide::autocomplete(world, doc, &source, cursor, explicit)?;
let lsp_start_position =
typst_to_lsp::offset_to_position(offset, position_encoding, &source);