mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-08-03 17:58:17 +00:00
fix: don't highlight breaks in contextual (#1635)
This commit is contained in:
parent
d6bce89e68
commit
01afa463f4
5 changed files with 14 additions and 15 deletions
|
@ -39,7 +39,8 @@ impl<'a> DocumentHighlightWorker<'a> {
|
|||
SyntaxKind::Arrow
|
||||
| SyntaxKind::Params
|
||||
| SyntaxKind::Return
|
||||
| SyntaxKind::FuncReturn => return self.work_func(node),
|
||||
| SyntaxKind::FuncReturn
|
||||
| SyntaxKind::Contextual => return self.work_func(node),
|
||||
_ => {}
|
||||
}
|
||||
node = node.parent()?;
|
||||
|
@ -50,8 +51,17 @@ impl<'a> DocumentHighlightWorker<'a> {
|
|||
let _ = self.ctx;
|
||||
|
||||
// find the nearest loop node
|
||||
let loop_node = node_ancestors(node)
|
||||
.find(|node| matches!(node.kind(), SyntaxKind::ForLoop | SyntaxKind::WhileLoop))?;
|
||||
let loop_node = 'find_loop: {
|
||||
for anc in node_ancestors(node) {
|
||||
if matches!(anc.kind(), SyntaxKind::Contextual | SyntaxKind::Closure) {
|
||||
return None;
|
||||
}
|
||||
if matches!(anc.kind(), SyntaxKind::ForLoop | SyntaxKind::WhileLoop) {
|
||||
break 'find_loop anc;
|
||||
}
|
||||
}
|
||||
return None;
|
||||
};
|
||||
|
||||
// find the first key word of the loop node
|
||||
let keyword = loop_node.children().find(|node| node.kind().is_keyword());
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
source: crates/tinymist-query/src/document_highlight.rs
|
||||
expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
|
||||
input_file: crates/tinymist-query/src/fixtures/document_highlight/base.typ
|
||||
snapshot_kind: text
|
||||
---
|
||||
[
|
||||
{
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
source: crates/tinymist-query/src/document_highlight.rs
|
||||
expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
|
||||
input_file: crates/tinymist-query/src/fixtures/document_highlight/nest.typ
|
||||
snapshot_kind: text
|
||||
---
|
||||
[
|
||||
{
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
source: crates/tinymist-query/src/document_highlight.rs
|
||||
expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
|
||||
input_file: crates/tinymist-query/src/fixtures/document_highlight/nest2.typ
|
||||
snapshot_kind: text
|
||||
---
|
||||
[
|
||||
{
|
||||
|
|
|
@ -2,13 +2,5 @@
|
|||
source: crates/tinymist-query/src/document_highlight.rs
|
||||
expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
|
||||
input_file: crates/tinymist-query/src/fixtures/document_highlight/syntax_error.typ
|
||||
snapshot_kind: text
|
||||
---
|
||||
[
|
||||
{
|
||||
"range": "0:0:0:4"
|
||||
},
|
||||
{
|
||||
"range": "1:2:1:7"
|
||||
}
|
||||
]
|
||||
null
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue