From 83ef0aea12c68372265ce388e1098e7dae36bb69 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Sun, 16 Jan 2022 20:05:58 -0600 Subject: [PATCH] prevent future matches for '#is-not? local' patterns --- highlight/src/lib.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/highlight/src/lib.rs b/highlight/src/lib.rs index 58d7e88c..e0016951 100644 --- a/highlight/src/lib.rs +++ b/highlight/src/lib.rs @@ -111,6 +111,7 @@ struct HighlightIterLayer<'a> { scope_stack: Vec>, ranges: Vec, depth: usize, + ignore_match_ids: Vec, } impl Highlighter { @@ -413,6 +414,7 @@ impl<'a> HighlightIterLayer<'a> { captures, config, ranges, + ignore_match_ids: Vec::new(), }); } @@ -683,6 +685,10 @@ where let (mut match_, capture_index) = layer.captures.next().unwrap(); let mut capture = match_.captures[capture_index]; + if layer.ignore_match_ids.contains(&match_.id()) { + continue 'main; + } + // If this capture represents an injection, then process the injection. if match_.pattern_index < layer.config.locals_pattern_index { let (language_name, content_node, include_children) = @@ -835,6 +841,7 @@ where // highlighting patterns that are disabled for local variables. if definition_highlight.is_some() || reference_highlight.is_some() { while layer.config.non_local_variable_patterns[match_.pattern_index] { + layer.ignore_match_ids.push(match_.id()); if let Some((next_match, next_capture_index)) = layer.captures.peek() { let next_capture = next_match.captures[*next_capture_index]; if next_capture.node == capture.node {