test: add completion tests about nodes in math calls (#1139)

This commit is contained in:
Myriad-Dreamin 2025-01-09 21:42:45 +08:00 committed by GitHub
parent db62791908
commit fb717ef4d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 248 additions and 0 deletions

View file

@ -173,7 +173,9 @@ impl<'a> CompletionCursor<'a> {
let syntax_context = classify_context(leaf.clone(), Some(cursor));
let surrounding_syntax = surrounding_syntax(&leaf);
crate::log_debug_ct!("CompletionCursor: syntax {leaf:?} -> {syntax:#?}");
crate::log_debug_ct!("CompletionCursor: context {leaf:?} -> {syntax_context:#?}");
crate::log_debug_ct!("CompletionCursor: surrounding {leaf:?} -> {surrounding_syntax:#?}");
Some(Self {
ctx,
text,

View file

@ -0,0 +1,3 @@
/// contains: abs
$ abs(abs/* range 0..1 */) $

View file

@ -0,0 +1,3 @@
/// contains: abs
$ abs(ab/* range 0..1 */) $

View file

@ -0,0 +1,3 @@
/// contains: abs
$ abs(1 a/* range 0..1 */) $

View file

@ -0,0 +1,3 @@
/// contains: abs
$ abs(1 ab/* range 0..1 */) $

View file

@ -0,0 +1,3 @@
/// contains: norm
$ abs(n/* range 0..1 */) $

View file

@ -0,0 +1,3 @@
/// contains: norm
$ abs(no/* range 0..1 */) $

View file

@ -0,0 +1,53 @@
---
source: crates/tinymist-query/src/completion.rs
description: Completion on / (28..29)
expression: "JsonRepr::new_pure(results)"
input_file: crates/tinymist-query/src/fixtures/completion/math_call_in_call.typ
snapshot_kind: text
---
[
{
"isIncomplete": false,
"items": [
{
"kind": 3,
"label": "abs",
"sortText": "000",
"textEdit": {
"newText": "abs(${1:})",
"range": {
"end": {
"character": 9,
"line": 2
},
"start": {
"character": 6,
"line": 2
}
}
}
},
{
"kind": 3,
"label": "abs",
"labelDetails": {
"description": "(content, size: auto | relative) => content"
},
"sortText": "058",
"textEdit": {
"newText": "abs(${1:})",
"range": {
"end": {
"character": 9,
"line": 2
},
"start": {
"character": 6,
"line": 2
}
}
}
}
]
}
]

View file

@ -0,0 +1,35 @@
---
source: crates/tinymist-query/src/completion.rs
description: Completion on / (27..28)
expression: "JsonRepr::new_pure(results)"
input_file: crates/tinymist-query/src/fixtures/completion/math_call_in_call2.typ
snapshot_kind: text
---
[
{
"isIncomplete": false,
"items": [
{
"kind": 3,
"label": "abs",
"labelDetails": {
"description": "(content, size: auto | relative) => content"
},
"sortText": "057",
"textEdit": {
"newText": "abs(${1:})",
"range": {
"end": {
"character": 8,
"line": 2
},
"start": {
"character": 6,
"line": 2
}
}
}
}
]
}
]

View file

@ -0,0 +1,35 @@
---
source: crates/tinymist-query/src/completion.rs
description: Completion on / (28..29)
expression: "JsonRepr::new_pure(results)"
input_file: crates/tinymist-query/src/fixtures/completion/math_call_in_call3.typ
snapshot_kind: text
---
[
{
"isIncomplete": false,
"items": [
{
"kind": 3,
"label": "abs",
"labelDetails": {
"description": "(content, size: auto | relative) => content"
},
"sortText": "055",
"textEdit": {
"newText": "abs(${1:})",
"range": {
"end": {
"character": 9,
"line": 2
},
"start": {
"character": 8,
"line": 2
}
}
}
}
]
}
]

View file

@ -0,0 +1,35 @@
---
source: crates/tinymist-query/src/completion.rs
description: Completion on / (29..30)
expression: "JsonRepr::new_pure(results)"
input_file: crates/tinymist-query/src/fixtures/completion/math_call_in_call4.typ
snapshot_kind: text
---
[
{
"isIncomplete": false,
"items": [
{
"kind": 3,
"label": "abs",
"labelDetails": {
"description": "(content, size: auto | relative) => content"
},
"sortText": "055",
"textEdit": {
"newText": "abs(${1:})",
"range": {
"end": {
"character": 10,
"line": 2
},
"start": {
"character": 8,
"line": 2
}
}
}
}
]
}
]

View file

@ -0,0 +1,35 @@
---
source: crates/tinymist-query/src/completion.rs
description: Completion on / (27..28)
expression: "JsonRepr::new_pure(results)"
input_file: crates/tinymist-query/src/fixtures/completion/math_ident_in_call.typ
snapshot_kind: text
---
[
{
"isIncomplete": false,
"items": [
{
"kind": 3,
"label": "norm",
"labelDetails": {
"description": "(content, size: auto | relative) => content"
},
"sortText": "221",
"textEdit": {
"newText": "norm(${1:})",
"range": {
"end": {
"character": 7,
"line": 2
},
"start": {
"character": 6,
"line": 2
}
}
}
}
]
}
]

View file

@ -0,0 +1,35 @@
---
source: crates/tinymist-query/src/completion.rs
description: Completion on / (28..29)
expression: "JsonRepr::new_pure(results)"
input_file: crates/tinymist-query/src/fixtures/completion/math_ident_in_call2.typ
snapshot_kind: text
---
[
{
"isIncomplete": false,
"items": [
{
"kind": 3,
"label": "norm",
"labelDetails": {
"description": "(content, size: auto | relative) => content"
},
"sortText": "223",
"textEdit": {
"newText": "norm(${1:})",
"range": {
"end": {
"character": 8,
"line": 2
},
"start": {
"character": 6,
"line": 2
}
}
}
}
]
}
]