fix: wrong checked prefix on completing strings (#422)

This commit is contained in:
Myriad-Dreamin 2024-07-17 15:34:33 +08:00 committed by GitHub
parent 134bd063be
commit 8413c66c51
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 4 additions and 4 deletions

View file

@ -199,8 +199,7 @@ impl StatefulRequest for CompletionRequest {
replace_range = ctx.to_lsp_range(rng, &source);
} else {
let lsp_start_position = ctx.to_lsp_pos(offset, &source);
replace_range = LspRange::new(lsp_start_position, self.position);
replace_range = ctx.to_lsp_range(offset..cursor, &source);
}
let completions = completions.iter().map(|typst_completion| {

View file

@ -36,7 +36,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/modify_string.typ
"label": "\"New Computer Modern\"",
"sortText": "003",
"textEdit": {
"newText": "New Computer Modern",
"newText": "\"New Computer Modern",
"range": {
"end": {
"character": 17,

View file

@ -1197,7 +1197,8 @@ impl<'a, 'w> CompletionContext<'a, 'w> {
*apply_label = trimmed;
}
}
if apply_label.starts_with('"') && self.before.ends_with('"') {
let from_before = slice_at(self.text, 0..self.from);
if apply_label.starts_with('"') && from_before.ends_with('"') {
if let Some(trimmed) = apply_label.strip_prefix('"') {
*apply_label = trimmed;
}