fix: complete body of let/closure in markup mode (#1072)

This commit is contained in:
Myriad-Dreamin 2024-12-26 16:47:57 +08:00 committed by GitHub
parent 1dcb034b91
commit 38941b8169
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 47 additions and 5 deletions

View file

@ -8,6 +8,27 @@ snapshot_kind: text
[
{
"isIncomplete": false,
"items": []
"items": [
{
"kind": 3,
"label": "pagebreak",
"labelDetails": {
"description": "(to: \"even\" | \"odd\" | none, weak: bool) => pagebreak"
},
"textEdit": {
"newText": "pagebreak()${1:}",
"range": {
"end": {
"character": 15,
"line": 2
},
"start": {
"character": 15,
"line": 2
}
}
}
}
]
}
]

View file

@ -8,6 +8,27 @@ snapshot_kind: text
[
{
"isIncomplete": false,
"items": []
"items": [
{
"kind": 3,
"label": "pagebreak",
"labelDetails": {
"description": "(to: \"even\" | \"odd\" | none, weak: bool) => pagebreak"
},
"textEdit": {
"newText": "pagebreak()${1:}",
"range": {
"end": {
"character": 12,
"line": 2
},
"start": {
"character": 12,
"line": 2
}
}
}
}
]
}
]

View file

@ -208,11 +208,11 @@ fn complete_markup(ctx: &mut CompletionContext) -> bool {
return true;
}
// Behind a half-completed binding: "#let x = |".
// Behind a half-completed binding: "#let x = |" or `#let f(x) = |`.
if_chain! {
if let Some(prev) = ctx.leaf.prev_leaf();
if prev.kind() == SyntaxKind::Eq;
if prev.parent_kind() == Some(SyntaxKind::LetBinding);
if matches!(prev.kind(), SyntaxKind::Eq | SyntaxKind::Arrow);
if matches!( prev.parent_kind(), Some(SyntaxKind::LetBinding | SyntaxKind::Closure));
then {
ctx.from = ctx.cursor;
code_completions(ctx, false);