From 0b5f0d606a060c9bcf062a983c760a0f9c4bab19 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Sun, 28 Jan 2024 14:48:57 -0500 Subject: [PATCH] Reverse syntax highlighting query precedence ordering --- helix-core/src/syntax.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs index 8fda29352..6b52ee40a 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -2475,15 +2475,17 @@ impl<'a> Iterator for HighlightIter<'a> { } } - // Once a highlighting pattern is found for the current node, skip over - // any later highlighting patterns that also match this node. Captures + // Use the last capture found for the current node, skipping over any + // highlight patterns that also match this node. Captures // for a given node are ordered by pattern index, so these subsequent // captures are guaranteed to be for highlighting, not injections or // local variables. while let Some((next_match, next_capture_index)) = captures.peek() { let next_capture = next_match.captures[*next_capture_index]; if next_capture.node == capture.node { - captures.next(); + match_.remove(); + capture = next_capture; + match_ = captures.next().unwrap().0; } else { break; }