fix: don't check context type of hash token (#1432)

This commit is contained in:
Myriad-Dreamin 2025-03-01 21:49:29 +08:00 committed by GitHub
parent 51530034f7
commit afc5d31377
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 153 additions and 4 deletions

View file

@ -181,10 +181,11 @@ impl<'a> PostTypeChecker<'a> {
None
};
let can_penetrate_context = !(matches!(context.kind(), SyntaxKind::FieldAccess) && {
let field_access = context.cast::<ast::FieldAccess>()?;
field_access.field().span() == node.span()
});
let can_penetrate_context = !(matches!(node.kind(), SyntaxKind::Hash)
|| matches!(context.kind(), SyntaxKind::FieldAccess) && {
let field_access = context.cast::<ast::FieldAccess>()?;
field_access.field().span() == node.span()
});
let contextual_self_ty = can_penetrate_context
.then(|| self.check_cursor(classify_context(node.clone(), None), context_ty));

View file

@ -0,0 +1,3 @@
/// contains: center, caption
#figure[# /* range -1..0 */]

View file

@ -0,0 +1,3 @@
/// contains: center, caption
#figure([# /* range -1..0 */])

View file

@ -0,0 +1,3 @@
/// contains: center, caption
#figure[#c /* range -1..0 */ ]

View file

@ -0,0 +1,3 @@
/// contains: center, caption
#figure([#c /* range -1..0 */ ])

View file

@ -0,0 +1,34 @@
---
source: crates/tinymist-query/src/completion.rs
description: Completion on (40..41)
expression: "JsonRepr::new_pure(results)"
input_file: crates/tinymist-query/src/fixtures/completion/arg_content.typ
---
[
{
"isIncomplete": false,
"items": [
{
"kind": 6,
"label": "center",
"labelDetails": {
"description": "alignment"
},
"sortText": "022",
"textEdit": {
"newText": "center",
"range": {
"end": {
"character": 9,
"line": 2
},
"start": {
"character": 9,
"line": 2
}
}
}
}
]
}
]

View file

@ -0,0 +1,34 @@
---
source: crates/tinymist-query/src/completion.rs
description: Completion on (41..42)
expression: "JsonRepr::new_pure(results)"
input_file: crates/tinymist-query/src/fixtures/completion/arg_content2.typ
---
[
{
"isIncomplete": false,
"items": [
{
"kind": 6,
"label": "center",
"labelDetails": {
"description": "alignment"
},
"sortText": "022",
"textEdit": {
"newText": "center",
"range": {
"end": {
"character": 10,
"line": 2
},
"start": {
"character": 10,
"line": 2
}
}
}
}
]
}
]

View file

@ -0,0 +1,34 @@
---
source: crates/tinymist-query/src/completion.rs
description: Completion on (41..42)
expression: "JsonRepr::new_pure(results)"
input_file: crates/tinymist-query/src/fixtures/completion/arg_content3.typ
---
[
{
"isIncomplete": false,
"items": [
{
"kind": 6,
"label": "center",
"labelDetails": {
"description": "alignment"
},
"sortText": "022",
"textEdit": {
"newText": "center",
"range": {
"end": {
"character": 10,
"line": 2
},
"start": {
"character": 9,
"line": 2
}
}
}
}
]
}
]

View file

@ -0,0 +1,34 @@
---
source: crates/tinymist-query/src/completion.rs
description: Completion on (42..43)
expression: "JsonRepr::new_pure(results)"
input_file: crates/tinymist-query/src/fixtures/completion/arg_content4.typ
---
[
{
"isIncomplete": false,
"items": [
{
"kind": 6,
"label": "center",
"labelDetails": {
"description": "alignment"
},
"sortText": "022",
"textEdit": {
"newText": "center",
"range": {
"end": {
"character": 11,
"line": 2
},
"start": {
"character": 10,
"line": 2
}
}
}
}
]
}
]