Skip to content

Commit

Permalink
Fix escape sequence highlighting bug in C++ include path and preproce…
Browse files Browse the repository at this point in the history
…ssor message.
  • Loading branch information
zufuliu committed Aug 13, 2023
1 parent 6e9969f commit 88420a4
Showing 1 changed file with 7 additions and 30 deletions.
37 changes: 7 additions & 30 deletions scintilla/lexers/LexCPP.cxx
Expand Up @@ -170,11 +170,6 @@ void ColouriseCppDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
while (sc.More()) {

if (sc.atLineStart) {
if (sc.state == SCE_C_STRING || sc.state == SCE_C_CHARACTER) {
// Prevent SCE_C_STRINGEOL from leaking back to previous line which
// ends with a line continuation by locking in the state upto this position.
sc.SetState(sc.state);
}
// Reset states to begining of colourise so no surprises
// if different sets of lines lexed.
visibleChars = 0;
Expand Down Expand Up @@ -376,17 +371,7 @@ void ColouriseCppDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
}
}

if ((isIncludePreprocessor && (sc.ch == '<' || sc.ch == '\"'))
|| (isMessagePreprocessor && !(sc.ch == '\n' || sc.ch == '\r'))) {
sc.SetState(SCE_C_STRING);
if (sc.ch == '\"') {
isIncludePreprocessor = false;
//isMessagePreprocessor = false;
}
sc.Forward();
} else {
sc.SetState(SCE_C_DEFAULT);
}
sc.SetState(isMessagePreprocessor ? SCE_C_STRING : SCE_C_DEFAULT);
}
break;

Expand Down Expand Up @@ -481,25 +466,19 @@ void ColouriseCppDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
}
break;

case SCE_C_STRINGEOL:
if (sc.atLineStart) {
outerStyle = SCE_C_DEFAULT;
sc.SetState(SCE_C_DEFAULT);
}
break;
case SCE_C_CHARACTER:
case SCE_C_STRING:
if (sc.atLineEnd) {
if (sc.atLineStart) {
isMessagePreprocessor = false;
sc.ChangeState(SCE_C_STRINGEOL);
isIncludePreprocessor = false;
outerStyle = SCE_C_DEFAULT;
sc.SetState(SCE_C_DEFAULT);
} else if (sc.ch == '>' && sc.state == SCE_C_STRING && isIncludePreprocessor) {
isIncludePreprocessor = false;
outerStyle = SCE_C_DEFAULT;
sc.ForwardSetState(SCE_C_DEFAULT);
isIncludePreprocessor = false;
} else if (sc.ch == '\\') {
if (isIncludePreprocessor) {
sc.Forward();
} else if (!IsEOLChar(sc.chNext)) {
if (!isIncludePreprocessor && !isMessagePreprocessor && !IsEOLChar(sc.chNext)) {
escSeq.resetEscapeState(sc.state, sc.chNext);
sc.SetState(SCE_C_ESCAPECHAR);
sc.Forward();
Expand Down Expand Up @@ -617,8 +596,6 @@ void ColouriseCppDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
sc.SetState(SCE_C_STRINGRAW);
sc.Forward();
} else if (sc.ch == '\"') {
isIncludePreprocessor = false;
//isMessagePreprocessor = false;
sc.SetState(SCE_C_STRING);
} else if (sc.ch == '\'') {
sc.SetState(SCE_C_CHARACTER);
Expand Down

0 comments on commit 88420a4

Please sign in to comment.