diff options
author | Colomban Wendling <ban@herbesfolles.org> | 2014-07-29 15:10:52 +0200 |
---|---|---|
committer | Colomban Wendling <ban@herbesfolles.org> | 2014-07-29 15:10:52 +0200 |
commit | d1c3348decc96c34b10eb54837d0bd355021dcba (patch) | |
tree | b6a7c970c0341d833b6e4f176a4d3fea2e46b350 | |
parent | e6b90e5b551f84aac17106873b6f6303fd2c19b0 (diff) | |
download | scintilla-mirror-d1c3348decc96c34b10eb54837d0bd355021dcba.tar.gz |
Allow global/class/instance variables as Ruby symbol literals
See comments in bug [#1627] for some details.
-rw-r--r-- | lexers/LexRuby.cxx | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lexers/LexRuby.cxx b/lexers/LexRuby.cxx index 0fdbab7d1..b0b52fd77 100644 --- a/lexers/LexRuby.cxx +++ b/lexers/LexRuby.cxx @@ -882,6 +882,31 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle, preferRE = false; } else if (isSafeWordcharOrHigh(chNext)) { state = SCE_RB_SYMBOL; + } else if ((chNext == '@' || chNext == '$') && + isSafeWordcharOrHigh(chNext2)) { + // instance and global variable followed by an identifier + advance_char(i, ch, chNext, chNext2); + state = SCE_RB_SYMBOL; + } else if (((chNext == '@' && chNext2 == '@') || + (chNext == '$' && chNext2 == '-')) && + isSafeWordcharOrHigh(styler.SafeGetCharAt(i+3))) { + // class variables and special global variable "$-IDENTCHAR" + state = SCE_RB_SYMBOL; + // $-IDENTCHAR doesn't continue past the IDENTCHAR + if (chNext == '$') { + styler.ColourTo(i+3, SCE_RB_SYMBOL); + state = SCE_RB_DEFAULT; + } + i += 3; + chNext = styler.SafeGetCharAt(i+1); + chNext2 = styler.SafeGetCharAt(i+2); + } else if (chNext == '$' && strchr("_~*$?!@/\\;,.=:<>\"&`'+", chNext2)) { + // single-character special global variables + i += 2; + ch = chNext2; + chNext = styler.SafeGetCharAt(i+1); + styler.ColourTo(i, SCE_RB_SYMBOL); + state = SCE_RB_DEFAULT; } else if (strchr("[*!~+-*/%=<>&^|", chNext)) { // Do the operator analysis in-line, looking ahead // Based on the table in pickaxe 2nd ed., page 339 |