diff options
author | nyamatongwe <unknown> | 2008-12-24 00:13:22 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2008-12-24 00:13:22 +0000 |
commit | 05b20097aa872a8baf77bef475bdab486ea03aa3 (patch) | |
tree | 5b5f1fb7e59652ab6c58556130779317534e5916 /src/LexPython.cxx | |
parent | 4ab387e7191b68fd4e72abdad4d11a0204be9ec9 (diff) | |
download | scintilla-mirror-05b20097aa872a8baf77bef475bdab486ea03aa3.tar.gz |
Fix for Bug #2450963 "Continued strings fool Python lexer" from Eric
Promislow.
Diffstat (limited to 'src/LexPython.cxx')
-rw-r--r-- | src/LexPython.cxx | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/src/LexPython.cxx b/src/LexPython.cxx index 7cc20e80a..b2c2f0558 100644 --- a/src/LexPython.cxx +++ b/src/LexPython.cxx @@ -105,12 +105,21 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle, if (startPos > 0) { if (lineCurrent > 0) { lineCurrent--; + // Look for backslash-continued lines + while (lineCurrent > 0) { + int eolPos = styler.LineStart(lineCurrent) - 1; + int eolStyle = styler.StyleAt(eolPos); + if (eolStyle == SCE_P_STRING + || eolStyle == SCE_P_CHARACTER + || eolStyle == SCE_P_STRINGEOL) { + lineCurrent -= 1; + } else { + break; + } + } startPos = styler.LineStart(lineCurrent); - if (startPos == 0) - initStyle = SCE_P_DEFAULT; - else - initStyle = styler.StyleAt(startPos - 1); } + initStyle = startPos == 0 ? SCE_P_DEFAULT : styler.StyleAt(startPos - 1); } WordList &keywords = *keywordlists[0]; @@ -132,6 +141,7 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle, bool indentGood = true; int startIndicator = sc.currentPos; + bool inContinuedString = false; for (; sc.More(); sc.Forward()) { @@ -163,8 +173,12 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle, } lineCurrent++; if ((sc.state == SCE_P_STRING) || (sc.state == SCE_P_CHARACTER)) { - sc.ChangeState(SCE_P_STRINGEOL); - sc.ForwardSetState(SCE_P_DEFAULT); + if (inContinuedString) { + inContinuedString = false; + } else { + sc.ChangeState(SCE_P_STRINGEOL); + sc.ForwardSetState(SCE_P_DEFAULT); + } } if (!sc.More()) break; @@ -225,7 +239,12 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle, if ((sc.chNext == '\r') && (sc.GetRelative(2) == '\n')) { sc.Forward(); } - sc.Forward(); + if (sc.chNext == '\n' || sc.chNext == '\r') { + inContinuedString = true; + } else { + // Don't roll over the newline. + sc.Forward(); + } } else if ((sc.state == SCE_P_STRING) && (sc.ch == '\"')) { sc.ForwardSetState(SCE_P_DEFAULT); needEOLCheck = true; |