diff --git a/src/row.rs b/src/row.rs index b71099c..9f7e61c 100644 --- a/src/row.rs +++ b/src/row.rs @@ -208,6 +208,7 @@ impl Row { } } + let mut prev_is_separator = true; let mut index = 0; while let Some(c) = chars.get(index) { if let Some(word) = word { @@ -221,12 +222,23 @@ impl Row { } } - if c.is_ascii_digit() { + let previous_highlight = if index > 0 { + highlighting + .get(index - 1) + .unwrap_or(&highlighting::Type::None) + } else { + &highlighting::Type::None + }; + + if c.is_ascii_digit() + && (prev_is_separator || previous_highlight == &highlighting::Type::Number) + { highlighting.push(highlighting::Type::Number) } else { highlighting.push(highlighting::Type::None) } + prev_is_separator = c.is_ascii_punctuation() || c.is_ascii_whitespace(); index += 1; }