From d57bfc057fba151d285da5c779009408d8fec532 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 21 Oct 2021 11:27:29 +0200 Subject: [PATCH] syntax: rust: do not colorize as string the text between two strings Strings may not contain a double quote unless it is escaped. Reference: https://doc.rust-lang.org/reference/tokens.html#string-literals (This will still not colorize multi-line strings with an unescaped newline, will still colorize "this\" as if it were a valid string, and will still miscolor things when there is another string after the closing quote of a two-line string. But those things can't be helped -- line-based regexes cannot emulate a full parser.) This fixes https://savannah.gnu.org/bugs/?61361. Reported-by: Elias Jonsson Bug existed since version 2.6.1, since the Rust syntax was introduced. --- syntax/rust.nanorc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/rust.nanorc b/syntax/rust.nanorc index 6b73c759..1a933ab3 100644 --- a/syntax/rust.nanorc +++ b/syntax/rust.nanorc @@ -22,8 +22,8 @@ color magenta "[A-Z][A-Z_0-9]+" color magenta "[A-Z][A-Za-z0-9]+" # Strings -color green "".*"" -color green start="".*\\$" end=".*"" +color green ""([^"]|\\")*"" +color green start=""([^"]|\\")*\\$" end=".*"" ## NOTE: This isn't accurate, but matching "#{0,} for the end of the string is too liberal. color green start="r#+"" end=""#+"