dev: check previous syntax first for show/set syntax (#859)

This commit is contained in:
Myriad-Dreamin 2024-11-20 02:43:10 +08:00 committed by GitHub
parent 6f8d9750d7
commit 698d86f9b0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 40 additions and 2 deletions

View file

@ -0,0 +1,5 @@
/// contains: raw, read, raw.with, raw.where, read.with, read.where, replacement, red
#show figure: it => {
set /* range 0..1 */
it
}

View file

@ -0,0 +1,33 @@
---
source: crates/tinymist-query/src/completion.rs
description: Completion on / (114..115)
expression: "JsonRepr::new_pure(results)"
input_file: crates/tinymist-query/src/fixtures/completion/set_in_show.typ
---
[
{
"isIncomplete": false,
"items": [
{
"kind": 3,
"label": "raw",
"labelDetails": {
"description": "(str, align: alignment, block: bool, lang: none | str, syntaxes: [syntax], tab-size: int, theme: [theme]) => raw"
},
"textEdit": {
"newText": "raw(${1:})",
"range": {
"end": {
"character": 6,
"line": 2
},
"start": {
"character": 6,
"line": 2
}
}
}
}
]
}
]

View file

@ -120,8 +120,8 @@ impl<'a> CompletionContext<'a> {
}
fn surrounding_syntax(&mut self) -> SurroundingSyntax {
check_surrounding_syntax(&self.leaf)
.or_else(|| check_previous_syntax(&self.leaf))
check_previous_syntax(&self.leaf)
.or_else(|| check_surrounding_syntax(&self.leaf))
.unwrap_or(SurroundingSyntax::Regular)
}