fix: complete field access even if its parent is a closure (#1019)

* dev: complete field access even if it's parent is a closure

* test: update snapshot
This commit is contained in:
Myriad-Dreamin 2024-12-18 15:06:57 +08:00 committed by GitHub
parent e116b0b645
commit 142138297e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 4 deletions

View file

@ -98,7 +98,12 @@ impl StatefulRequest for CompletionRequest {
let parent_init = parent.find(parent_init.span())?;
parent_init.find(node.span())?;
}
Some(SyntaxKind::Closure) => return None,
Some(SyntaxKind::Closure) => {
let parent = node.parent()?;
let parent_body = parent.cast::<ast::Closure>()?.body();
let parent_body = parent.find(parent_body.span())?;
parent_body.find(node.span())?;
}
_ => {}
}
}

View file

@ -1,10 +1,13 @@
---
source: crates/tinymist-query/src/completion.rs
description: Completion on / (55..56)
description: Completion on / (51..52)
expression: "JsonRepr::new_pure(results)"
input_file: crates/tinymist-query/src/fixtures/completion/field_simple.typ
snapshot_kind: text
---
[
null
{
"isIncomplete": false,
"items": []
}
]

View file

@ -374,7 +374,7 @@ fn e2e() {
});
let hash = replay_log(&tinymist_binary, &root.join("neovim"));
insta::assert_snapshot!(hash, @"siphash128_13:1b57e3cb3fd4ba2a088a4eaf7aa6d4bb");
insta::assert_snapshot!(hash, @"siphash128_13:a46fdba2828c3e0b2fa431509c12d45e");
}
{