aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/syntax_highlighting/format.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-01-07 22:39:02 +0000
committerAleksey Kladov <[email protected]>2021-01-08 20:47:35 +0000
commite30c1c3fbf8f70336d985b2b73e5b0f45f3b95f5 (patch)
treea3cdc2d2f667ab5a122758152eb338a654d387cd /crates/ide/src/syntax_highlighting/format.rs
parent981a0d708ec352969f9ca075a3e0e50c6da48197 (diff)
Simplify highlighting infra
This also fixes the killer whale bug
Diffstat (limited to 'crates/ide/src/syntax_highlighting/format.rs')
-rw-r--r--crates/ide/src/syntax_highlighting/format.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/crates/ide/src/syntax_highlighting/format.rs b/crates/ide/src/syntax_highlighting/format.rs
index 26416022b..ab66b406c 100644
--- a/crates/ide/src/syntax_highlighting/format.rs
+++ b/crates/ide/src/syntax_highlighting/format.rs
@@ -4,9 +4,9 @@ use syntax::{
4 AstNode, AstToken, SyntaxElement, SyntaxKind, SyntaxNode, TextRange, 4 AstNode, AstToken, SyntaxElement, SyntaxKind, SyntaxNode, TextRange,
5}; 5};
6 6
7use crate::{ 7use crate::{HighlightTag, HighlightedRange, SymbolKind};
8 syntax_highlighting::HighlightedRangeStack, HighlightTag, HighlightedRange, SymbolKind, 8
9}; 9use super::highlights::Highlights;
10 10
11#[derive(Default)] 11#[derive(Default)]
12pub(super) struct FormatStringHighlighter { 12pub(super) struct FormatStringHighlighter {
@@ -39,22 +39,20 @@ impl FormatStringHighlighter {
39 } 39 }
40 pub(super) fn highlight_format_string( 40 pub(super) fn highlight_format_string(
41 &self, 41 &self,
42 range_stack: &mut HighlightedRangeStack, 42 stack: &mut Highlights,
43 string: &impl HasFormatSpecifier, 43 string: &impl HasFormatSpecifier,
44 range: TextRange, 44 range: TextRange,
45 ) { 45 ) {
46 if self.format_string.as_ref() == Some(&SyntaxElement::from(string.syntax().clone())) { 46 if self.format_string.as_ref() == Some(&SyntaxElement::from(string.syntax().clone())) {
47 range_stack.push();
48 string.lex_format_specifier(|piece_range, kind| { 47 string.lex_format_specifier(|piece_range, kind| {
49 if let Some(highlight) = highlight_format_specifier(kind) { 48 if let Some(highlight) = highlight_format_specifier(kind) {
50 range_stack.add(HighlightedRange { 49 stack.add(HighlightedRange {
51 range: piece_range + range.start(), 50 range: piece_range + range.start(),
52 highlight: highlight.into(), 51 highlight: highlight.into(),
53 binding_hash: None, 52 binding_hash: None,
54 }); 53 });
55 } 54 }
56 }); 55 });
57 range_stack.pop();
58 } 56 }
59 } 57 }
60} 58}