Skip to content

Commit 1e347a1

Browse files
zufuliunyamatongwe
authored andcommitted
#124 Disambiguate %= which may be a quote or modulo assignment.
https://sourceforge.net/p/scintilla/bugs/1255/
1 parent 02fafaa commit 1e347a1

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

lexers/LexRuby.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ void ColouriseRbDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
10821082
Quote.Open(chNext);
10831083
advance_char(i, ch, chNext, chNext2); // pass by ref
10841084
have_string = true;
1085-
} else if (!isSafeWordcharOrHigh(chNext) && !iswhitespace(chNext) && !isEOLChar(chNext)) {
1085+
} else if (!isSafeWordcharOrHigh(chNext) && !iswhitespace(chNext) && !isEOLChar(chNext) && chNext != '=') {
10861086
// Ruby doesn't allow high bit chars here,
10871087
// but the editor host might
10881088
Quote.New();
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Issue 124, disambiguating %= which may be a quote or modulo assignment
2+
# %-quoting with '=' as the quote
3+
s = %=3=
4+
puts s
5+
x = 7
6+
# Modulo assignment, equivalent to x = x % 2
7+
x %=2
8+
puts x
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
0 400 0 # Issue 124, disambiguating %= which may be a quote or modulo assignment
2+
0 400 0 # %-quoting with '=' as the quote
3+
0 400 0 s = %=3=
4+
0 400 0 puts s
5+
0 400 0 x = 7
6+
0 400 0 # Modulo assignment, equivalent to x = x % 2
7+
0 400 0 x %=2
8+
0 400 0 puts x
9+
0 400 0
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{2}# Issue 124, disambiguating %= which may be a quote or modulo assignment{0}
2+
{2}# %-quoting with '=' as the quote{0}
3+
{11}s{0} {10}={0} {25}%=3={0}
4+
{11}puts{0} {11}s{0}
5+
{11}x{0} {10}={0} {4}7{0}
6+
{2}# Modulo assignment, equivalent to x = x % 2{0}
7+
{11}x{0} {10}%={4}2{0}
8+
{11}puts{0} {11}x{0}

0 commit comments

Comments
 (0)