Skip to content

Commit ed81a17

Browse files
committed
Improve '&&' and '&' syntax highlighting by altering StringName highlighting
1 parent 46c8f8c commit ed81a17

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

modules/gdscript/editor/gdscript_highlighter.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -560,12 +560,17 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l
560560
}
561561
}
562562

563-
// Keep symbol color for binary '&&'. In the case of '&&&' use StringName color for the last ampersand.
563+
// Set color of StringName, keeping symbol color for binary '&&' and '&'.
564564
if (!in_string_name && in_region == -1 && str[j] == '&' && !is_binary_op) {
565-
if (j >= 2 && str[j - 1] == '&' && str[j - 2] != '&' && prev_is_binary_op) {
566-
is_binary_op = true;
567-
} else if (j == 0 || (j > 0 && str[j - 1] != '&') || prev_is_binary_op) {
565+
if (j + 1 <= line_length - 1 && (str[j + 1] == '\'' || str[j + 1] == '"')) {
568566
in_string_name = true;
567+
// Cover edge cases of i.e. '+&""' and '&&&""', so the StringName is properly colored.
568+
if (prev_is_binary_op && j >= 2 && str[j - 1] == '&' && str[j - 2] != '&') {
569+
in_string_name = false;
570+
is_binary_op = true;
571+
}
572+
} else {
573+
is_binary_op = true;
569574
}
570575
} else if (in_region != -1 || is_a_symbol) {
571576
in_string_name = false;

0 commit comments

Comments
 (0)