From 7e40fc996be11d0ab1b4735872f5fb48f6a59aac Mon Sep 17 00:00:00 2001 From: pommicket Date: Thu, 15 Jun 2023 11:09:19 +0100 Subject: prevent /= from being parsed as regex literal --- syntax.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/syntax.c b/syntax.c index e7ee69d..1a5e1cf 100644 --- a/syntax.c +++ b/syntax.c @@ -1390,6 +1390,12 @@ static void syntax_highlight_javascript_like( || (is32_space(line[i-1]) && i + 1 < line_len && !is32_space(line[i+1])) // slash preceded by any of these characters || (line[i-1] <= 128 && strchr(";({[=,:", (char)line[i-1])); + + if (i + 1 < line_len && line[i+1] == '=') { + // slash is followed by equals, so this might be /= + is_regex = false; + } + if (is_regex) { in_string = true; string_is_regex = true; -- cgit v1.2.3