From 5277bae9ad8e6fa1041190c96c3c1d4e2924cbbe Mon Sep 17 00:00:00 2001 From: MSebanc Date: Wed, 22 Jan 2025 14:18:07 -0800 Subject: [PATCH 1/2] Fixed cli highlighting error --- tools/shell/linenoise.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tools/shell/linenoise.cpp b/tools/shell/linenoise.cpp index 9acfbd2e139..ba4e07b7261 100644 --- a/tools/shell/linenoise.cpp +++ b/tools/shell/linenoise.cpp @@ -1760,8 +1760,7 @@ void addErrorHighlighting(uint64_t render_start, uint64_t render_end, case ScanState::IN_SINGLE_QUOTE: // single quote - all that will get us out is an unescaped single-quote if (c == '\'') { - if (i + 1 < l->len && l->buf[i + 1] == '\'') { - // double single-quote means the quote is escaped - continue + if (i > 0 && l->buf[i - 1] == '\\') { // escaped quote i++; break; } else { @@ -1772,10 +1771,9 @@ void addErrorHighlighting(uint64_t render_start, uint64_t render_end, } break; case ScanState::IN_DOUBLE_QUOTE: - // double quote - all that will get us out is an unescaped quote + // quote - all that will get us out is an unescaped quote if (c == '"') { - if (i + 1 < l->len && l->buf[i + 1] == '"') { - // double quote means the quote is escaped - continue + if (i > 0 && l->buf[i - 1] == '\\') { // escaped quote i++; break; } else { From 15cc62914c13061a94744b54ffcf2f8abc297978 Mon Sep 17 00:00:00 2001 From: MSebanc Date: Wed, 22 Jan 2025 14:26:21 -0800 Subject: [PATCH 2/2] updated comment --- tools/shell/linenoise.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/shell/linenoise.cpp b/tools/shell/linenoise.cpp index ba4e07b7261..1e82b710c48 100644 --- a/tools/shell/linenoise.cpp +++ b/tools/shell/linenoise.cpp @@ -1771,7 +1771,7 @@ void addErrorHighlighting(uint64_t render_start, uint64_t render_end, } break; case ScanState::IN_DOUBLE_QUOTE: - // quote - all that will get us out is an unescaped quote + // double quote - all that will get us out is an unescaped quote if (c == '"') { if (i > 0 && l->buf[i - 1] == '\\') { // escaped quote i++;