From 6267dc48881f55ee28deed5e6be1c55df31ff29d Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 16 Mar 2021 10:49:15 -0400 Subject: [PATCH] Continue highlighting escaped characters --- src/row.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/row.rs b/src/row.rs index 3384563..57da1cb 100644 --- a/src/row.rs +++ b/src/row.rs @@ -235,6 +235,14 @@ impl Row { if opts.strings() { if in_string { highlighting.push(highlighting::Type::String); + + // Don't let an escaped character stop string highlighting + if *c == '\\' && index < self.len().saturating_sub(1) { + highlighting.push(highlighting::Type::String); + index += 2; + continue; + } + if *c == '"' { in_string = false; prev_is_separator = true; @@ -256,8 +264,8 @@ impl Row { if opts.numbers() { if (c.is_ascii_digit() - && (prev_is_separator || previous_highlight == &highlighting::Type::Number)) - || (c == &'.' && previous_highlight == &highlighting::Type::Number) + && (prev_is_separator || *previous_highlight == highlighting::Type::Number)) + || (*c == '.' && *previous_highlight == highlighting::Type::Number) { highlighting.push(highlighting::Type::Number) } else {