Skip to content

Commit 9984e73

Browse files
committed
Fix highlighting of identifiers before brackets
1 parent 2606034 commit 9984e73

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/ide/highlight.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,13 @@ fn highlight_ident(node: &LinkedNode) -> Option<Tag> {
261261
let next_leaf = node.next_leaf();
262262
if let Some(next) = &next_leaf {
263263
if node.range().end == next.offset()
264-
&& next.kind() == SyntaxKind::LeftParen
265-
&& matches!(next.parent_kind(), Some(SyntaxKind::Args | SyntaxKind::Params))
266-
|| (next.kind() == SyntaxKind::LeftBracket
267-
&& next.parent_kind() == Some(SyntaxKind::ContentBlock))
264+
&& ((next.kind() == SyntaxKind::LeftParen
265+
&& matches!(
266+
next.parent_kind(),
267+
Some(SyntaxKind::Args | SyntaxKind::Params)
268+
))
269+
|| (next.kind() == SyntaxKind::LeftBracket
270+
&& next.parent_kind() == Some(SyntaxKind::ContentBlock)))
268271
{
269272
return Some(Tag::Function);
270273
}

tests/ref/compiler/highlight.png

1.16 KB
Loading

tests/typ/compiler/highlight.typ

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ $ #hello() $
3838
$ #hello.world $
3939
$ #hello.world() $
4040
$ #box[] $
41+
#if foo []
4142
```

0 commit comments

Comments
 (0)