mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-08-03 17:58:17 +00:00
fix: correct order to insert definitions in scope (#1116)
This commit is contained in:
parent
bb66b4b97a
commit
b7feb5dcca
5 changed files with 88 additions and 7 deletions
|
@ -54,13 +54,6 @@ impl CompletionPair<'_, '_, '_> {
|
|||
};
|
||||
|
||||
let mode = interpret_mode_at(Some(&self.cursor.leaf));
|
||||
let in_math = matches!(mode, InterpretMode::Math);
|
||||
|
||||
let lib = self.worker.world().library();
|
||||
let scope = if in_math { &lib.math } else { &lib.global }
|
||||
.scope()
|
||||
.clone();
|
||||
defines.insert_scope(&scope);
|
||||
|
||||
previous_decls(self.cursor.leaf.clone(), |node| -> Option<()> {
|
||||
match node {
|
||||
|
@ -93,6 +86,14 @@ impl CompletionPair<'_, '_, '_> {
|
|||
None
|
||||
});
|
||||
|
||||
let in_math = matches!(mode, InterpretMode::Math);
|
||||
|
||||
let lib = self.worker.world().library();
|
||||
let scope = if in_math { &lib.math } else { &lib.global }
|
||||
.scope()
|
||||
.clone();
|
||||
defines.insert_scope(&scope);
|
||||
|
||||
Some(defines)
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
/// contains: pagebreak
|
||||
|
||||
#let pagebreak(fill-rest: false) = { }
|
||||
|
||||
#pageb(/* range -1..0 */ )
|
|
@ -0,0 +1,5 @@
|
|||
/// contains: pagebreak
|
||||
|
||||
#let pagebreak(fill-rest: false) = { }
|
||||
|
||||
#page(/* range -1..0 */ )
|
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
source: crates/tinymist-query/src/completion.rs
|
||||
description: Completion on ( (71..72)
|
||||
expression: "JsonRepr::new_pure(results)"
|
||||
input_file: crates/tinymist-query/src/fixtures/completion/builtin_shadow.typ
|
||||
snapshot_kind: text
|
||||
---
|
||||
[
|
||||
{
|
||||
"isIncomplete": false,
|
||||
"items": [
|
||||
{
|
||||
"kind": 3,
|
||||
"label": "pagebreak",
|
||||
"labelDetails": {
|
||||
"description": "(fill-rest: false) => none"
|
||||
},
|
||||
"sortText": "126",
|
||||
"textEdit": {
|
||||
"newText": "pagebreak()${1:}",
|
||||
"range": {
|
||||
"end": {
|
||||
"character": 6,
|
||||
"line": 4
|
||||
},
|
||||
"start": {
|
||||
"character": 1,
|
||||
"line": 4
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
source: crates/tinymist-query/src/completion.rs
|
||||
description: Completion on ( (70..71)
|
||||
expression: "JsonRepr::new_pure(results)"
|
||||
input_file: crates/tinymist-query/src/fixtures/completion/builtin_shadow_existing.typ
|
||||
snapshot_kind: text
|
||||
---
|
||||
[
|
||||
{
|
||||
"isIncomplete": false,
|
||||
"items": [
|
||||
{
|
||||
"kind": 3,
|
||||
"label": "pagebreak",
|
||||
"labelDetails": {
|
||||
"description": "(fill-rest: false) => none"
|
||||
},
|
||||
"sortText": "127",
|
||||
"textEdit": {
|
||||
"newText": "pagebreak()${1:}",
|
||||
"range": {
|
||||
"end": {
|
||||
"character": 5,
|
||||
"line": 4
|
||||
},
|
||||
"start": {
|
||||
"character": 1,
|
||||
"line": 4
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
Loading…
Add table
Add a link
Reference in a new issue