mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-07-24 13:13:43 +00:00
fix: deduplicate value completion correctly (#604)
This commit is contained in:
parent
6ce6bb8018
commit
fcde0efb22
3 changed files with 94 additions and 3 deletions
|
@ -0,0 +1,10 @@
|
|||
// contains:a,ab,ac,ad
|
||||
|
||||
#let x = (
|
||||
a: false,
|
||||
ab: false,
|
||||
ac: false,
|
||||
ad: true,
|
||||
)
|
||||
|
||||
#x.a /* range -1..0 */
|
|
@ -0,0 +1,81 @@
|
|||
---
|
||||
source: crates/tinymist-query/src/completion.rs
|
||||
description: Completion on (92..93)
|
||||
expression: "JsonRepr::new_pure(results)"
|
||||
input_file: crates/tinymist-query/src/fixtures/completion/fp_dict_filter.typ
|
||||
---
|
||||
[
|
||||
{
|
||||
"isIncomplete": false,
|
||||
"items": [
|
||||
{
|
||||
"kind": 21,
|
||||
"label": "a",
|
||||
"textEdit": {
|
||||
"newText": "a",
|
||||
"range": {
|
||||
"end": {
|
||||
"character": 4,
|
||||
"line": 9
|
||||
},
|
||||
"start": {
|
||||
"character": 3,
|
||||
"line": 9
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": 21,
|
||||
"label": "ab",
|
||||
"textEdit": {
|
||||
"newText": "ab",
|
||||
"range": {
|
||||
"end": {
|
||||
"character": 4,
|
||||
"line": 9
|
||||
},
|
||||
"start": {
|
||||
"character": 3,
|
||||
"line": 9
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": 21,
|
||||
"label": "ac",
|
||||
"textEdit": {
|
||||
"newText": "ac",
|
||||
"range": {
|
||||
"end": {
|
||||
"character": 4,
|
||||
"line": 9
|
||||
},
|
||||
"start": {
|
||||
"character": 3,
|
||||
"line": 9
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": 21,
|
||||
"label": "ad",
|
||||
"textEdit": {
|
||||
"newText": "ad",
|
||||
"range": {
|
||||
"end": {
|
||||
"character": 4,
|
||||
"line": 9
|
||||
},
|
||||
"start": {
|
||||
"character": 3,
|
||||
"line": 9
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -10,7 +10,7 @@ use typst::model::Document;
|
|||
use typst::syntax::ast::AstNode;
|
||||
use typst::syntax::{ast, is_id_continue, is_id_start, is_ident, LinkedNode, Source, SyntaxKind};
|
||||
use typst::text::RawElem;
|
||||
use typst_shim::syntax::LinkedNodeExt;
|
||||
use typst_shim::{syntax::LinkedNodeExt, utils::hash128};
|
||||
use unscanny::Scanner;
|
||||
|
||||
use super::{plain_docs_sentence, summarize_font_family};
|
||||
|
@ -1138,7 +1138,7 @@ impl<'a, 'w> CompletionContext<'a, 'w> {
|
|||
bib_title,
|
||||
} in labels.into_iter().skip(skip).take(take)
|
||||
{
|
||||
if !self.seen_casts.insert(typst_shim::utils::hash128(&label)) {
|
||||
if !self.seen_casts.insert(hash128(&label)) {
|
||||
continue;
|
||||
}
|
||||
let label: EcoString = label.as_str().into();
|
||||
|
@ -1204,7 +1204,7 @@ impl<'a, 'w> CompletionContext<'a, 'w> {
|
|||
docs: Option<&str>,
|
||||
) {
|
||||
// Prevent duplicate completions from appearing.
|
||||
if !self.seen_casts.insert(typst_shim::utils::hash128(value)) {
|
||||
if !self.seen_casts.insert(hash128(&(&label, &value))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue