Skip to content

Commit 19d894c

Browse files
committed
minor: Cleanup syntax highlighting
1 parent 22160c4 commit 19d894c

File tree

5 files changed

+209
-235
lines changed

5 files changed

+209
-235
lines changed

crates/ide/src/syntax_highlighting.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ fn traverse(
265265
}
266266

267267
let element = match event {
268+
WalkEvent::Enter(NodeOrToken::Token(tok)) if tok.kind() == WHITESPACE => continue,
268269
WalkEvent::Enter(it) => it,
269270
WalkEvent::Leave(NodeOrToken::Token(_)) => continue,
270271
WalkEvent::Leave(NodeOrToken::Node(node)) => {
@@ -347,13 +348,16 @@ fn traverse(
347348
}
348349

349350
// do the normal highlighting
350-
let element = highlight::element(
351-
sema,
352-
krate,
353-
&mut bindings_shadow_count,
354-
syntactic_name_ref_highlighting,
355-
element_to_highlight,
356-
);
351+
let element = match element_to_highlight {
352+
NodeOrToken::Node(node) => highlight::node(
353+
sema,
354+
krate,
355+
&mut bindings_shadow_count,
356+
syntactic_name_ref_highlighting,
357+
node,
358+
),
359+
NodeOrToken::Token(token) => highlight::token(sema, krate, token).zip(Some(None)),
360+
};
357361
if let Some((mut highlight, binding_hash)) = element {
358362
if inside_attribute {
359363
highlight |= HlMod::Attribute

0 commit comments

Comments
 (0)