fix: forbid ident code completion in field access (#1020)

* feat: forbid ident code completion in field access

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

View file

@ -8,27 +8,6 @@ snapshot_kind: text
[
{
"isIncomplete": false,
"items": [
{
"kind": 3,
"label": "text",
"labelDetails": {
"description": "(content, str, alternates: bool, baseline: length, bottom-edge: \"baseline\" | \"bounds\" | \"descender\" | length, cjk-latin-spacing: auto | none, costs: dictionary, dir: dir, discretionary-ligatures: bool, fallback: bool, features: array | dictionary, fill: color, font: array | text.font, fractions: bool, historical-ligatures: bool, hyphenate: auto | bool, kerning: bool, lang: text.lang, ligatures: bool, number-type: \"lining\" | \"old-style\" | auto, number-width: \"proportional\" | \"tabular\" | auto, overhang: bool, region: text.region, script: auto | str, size: text.size, slashed-zero: bool, spacing: relative, stretch: ratio, stroke: stroke, style: \"italic\" | \"normal\" | \"oblique\", stylistic-set: array | int | none, top-edge: \"ascender\" | \"baseline\" | \"bounds\" | \"cap-height\" | \"x-height\" | length, tracking: length, weight: \"black\" | \"bold\" | \"extrabold\" | \"extralight\" | \"light\" | \"medium\" | \"regular\" | \"semibold\" | \"thin\" | int) => text"
},
"textEdit": {
"newText": "text(${1:}), ",
"range": {
"end": {
"character": 71,
"line": 2
},
"start": {
"character": 70,
"line": 2
}
}
}
}
]
"items": []
}
]

View file

@ -526,7 +526,9 @@ fn complete_code(ctx: &mut CompletionContext, from_type: bool) -> bool {
}
// An existing identifier: "{ pa| }".
if ctx.leaf.kind() == SyntaxKind::Ident {
if ctx.leaf.kind() == SyntaxKind::Ident
&& !matches!(ctx.leaf.parent_kind(), Some(SyntaxKind::FieldAccess))
{
ctx.from = ctx.leaf.offset();
code_completions(ctx, false);
return true;