diff options
author | nyamatongwe <devnull@localhost> | 2005-11-08 23:44:20 +0000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2005-11-08 23:44:20 +0000 |
commit | 740d35f48cd7db8ebaed67df09d6604def4825b9 (patch) | |
tree | fc3a8d353c6fdeaecf72450d11e1793851a1ad4d | |
parent | 9fc46d187f9cb1a7be7e2215be572e95549be510 (diff) | |
download | scintilla-mirror-740d35f48cd7db8ebaed67df09d6604def4825b9.tar.gz |
Fixed bug where preprocessor statements that were continued onto
the next line using '\' dropped the preprocessor style after the first
line.
-rw-r--r-- | src/LexCPP.cxx | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/LexCPP.cxx b/src/LexCPP.cxx index 95433e3db..cd2755243 100644 --- a/src/LexCPP.cxx +++ b/src/LexCPP.cxx @@ -56,6 +56,23 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo int visibleChars = 0; bool lastWordWasUUID = false; int styleBeforeDCKeyword = SCE_C_DEFAULT; + bool continuationLine = false; + + if (initStyle == SCE_C_PREPROCESSOR) { + // Set continuationLine if last character of previous line is '\' + int lineCurrent = styler.GetLine(startPos); + if (lineCurrent > 0) { + int chBack = styler.SafeGetCharAt(startPos-1, 0); + int chBack2 = styler.SafeGetCharAt(startPos-2, 0); + int lineEndChar = '!'; + if (chBack2 == '\r' && chBack == '\n') { + lineEndChar = styler.SafeGetCharAt(startPos-3, 0); + } else if (chBack == '\n' || chBack == '\r') { + lineEndChar = chBack2; + } + continuationLine = lineEndChar == '\\'; + } + } StyleContext sc(startPos, length, initStyle, styler); @@ -81,6 +98,7 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo if (sc.ch == '\r' && sc.chNext == '\n') { sc.Forward(); } + continuationLine = true; continue; } } @@ -116,7 +134,7 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo } break; case SCE_C_PREPROCESSOR: - if (sc.atLineStart) { + if (sc.atLineStart && !continuationLine) { sc.SetState(SCE_C_DEFAULT); } else if (stylingWithinPreprocessor) { if (IsASpace(sc.ch)) { @@ -291,6 +309,7 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo chPrevNonWhite = sc.ch; visibleChars++; } + continuationLine = false; } sc.Complete(); } |