diff options
| author | nyamatongwe <unknown> | 2010-10-20 14:59:24 +1100 | 
|---|---|---|
| committer | nyamatongwe <unknown> | 2010-10-20 14:59:24 +1100 | 
| commit | bb013a457fe27b0cff6632739a7935ce103cfe71 (patch) | |
| tree | 008fc0a59972a8a37fdf93625df4b6eb5346ec21 | |
| parent | ecd5e7da1c84b0165203ca29335f74142b50f073 (diff) | |
| download | scintilla-mirror-bb013a457fe27b0cff6632739a7935ce103cfe71.tar.gz | |
Folding fix for "if" keyword used as a modifier where it is separated
from the modified statement by an escaped new line.
From bug #2093767.
| -rw-r--r-- | lexers/LexRuby.cxx | 41 | 
1 files changed, 38 insertions, 3 deletions
diff --git a/lexers/LexRuby.cxx b/lexers/LexRuby.cxx index 402b8da32..b74ea146c 100644 --- a/lexers/LexRuby.cxx +++ b/lexers/LexRuby.cxx @@ -1457,10 +1457,32 @@ static bool keywordIsModifier(const char *word,      if (word[0] == 'd' && word[1] == 'o' && !word[2]) {          return keywordDoStartsLoop(pos, styler);      } -    char ch; +    char ch, chPrev, chPrev2;      int style = SCE_RB_DEFAULT;  	int lineStart = styler.GetLine(pos);      int lineStartPosn = styler.LineStart(lineStart); +    // We want to step backwards until we don't care about the current +    // position. But first move lineStartPosn back behind any +    // continuations immediately above word. +    while (lineStartPosn > 0) { +        ch = styler[lineStartPosn-1]; +        if (ch == '\n' || ch == '\r') { +            chPrev  = styler.SafeGetCharAt(lineStartPosn-2); +            chPrev2 = styler.SafeGetCharAt(lineStartPosn-3); +            lineStart = styler.GetLine(lineStartPosn-1); +            // If we find a continuation line, include it in our analysis. +            if (chPrev == '\\') { +                lineStartPosn = styler.LineStart(lineStart); +            } else if (ch == '\n' && chPrev == '\r' && chPrev2 == '\\') { +                lineStartPosn = styler.LineStart(lineStart); +            } else { +                break; +            } +        } else { +          break; +        } +    } +          styler.Flush();      while (--pos >= lineStartPosn) {          style = actual_style(styler.StyleAt(pos)); @@ -1471,14 +1493,27 @@ static bool keywordIsModifier(const char *word,  				// Scintilla's LineStart() and GetLine() routines aren't  				// platform-independent, so if we have text prepared with  				// a different system we can't rely on it. -				return false; +                 +                // Also, lineStartPosn may have been moved to more than one +                // line above word's line while pushing past continuations. +                chPrev = styler.SafeGetCharAt(pos - 1); +                chPrev2 = styler.SafeGetCharAt(pos - 2); +                if (chPrev == '\\') { +                    pos-=1;  // gloss over the "\\" +                    //continue +                } else if (ch == '\n' && chPrev == '\r' && chPrev2 == '\\') { +                    pos-=2;  // gloss over the "\\\r" +                    //continue +                } else { +				    return false; +                }  			}  		} else {              break;  		}      }      if (pos < lineStartPosn) { -        return false; //XXX not quite right if the prev line is a continuation +        return false;      }      // First things where the action is unambiguous      switch (style) {  | 
