aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authornyamatongwe <unknown>2005-11-08 23:44:20 +0000
committernyamatongwe <unknown>2005-11-08 23:44:20 +0000
commit3ac5c3a6ad55a035df336103693631ae15c9387a (patch)
treefc3a8d353c6fdeaecf72450d11e1793851a1ad4d /src
parent0efac4bb3dac7790046906c25bccff86f0ca5da4 (diff)
downloadscintilla-mirror-3ac5c3a6ad55a035df336103693631ae15c9387a.tar.gz
Fixed bug where preprocessor statements that were continued onto
the next line using '\' dropped the preprocessor style after the first line.
Diffstat (limited to 'src')
-rw-r--r--src/LexCPP.cxx21
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();
}