Skip to content

Commit

Permalink
Minor fix for Python nested f-string highlighting.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed May 19, 2023
1 parent 9ad212f commit 85c9f0c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions scintilla/lexers/LexPython.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -552,18 +552,18 @@ void ColourisePyDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyl

case '{':
if (IsPyString(sc.state)) {
if (sc.chNext == '{') {
if (sc.chNext == '{' && fstringPart == FormattedStringPart::None) {
escSeq.outerState = sc.state;
escSeq.digitsLeft = 1;
sc.SetState(SCE_PY_ESCAPECHAR);
sc.Forward();
} else if (IsPyFormattedString(sc.state)) {
if (nestedState.empty()) {
fstringPart = FormattedStringPart::None;
nestedState.push_back({sc.state, 1, 0});
} else {
nestedState.back().nestedLevel += 1;
}
fstringPart = FormattedStringPart::None;
sc.SetState(SCE_PY_OPERATOR2);
sc.ForwardSetState(SCE_PY_DEFAULT);
} else if (sc.chNext == '}' || sc.chNext == '!' || sc.chNext == ':' || IsIdentifierCharEx(sc.chNext)) {
Expand All @@ -582,14 +582,14 @@ void ColourisePyDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyl
if (state.nestedLevel > 1) {
--state.nestedLevel;
} else {
fstringPart = FormattedStringPart::None;
nestedState.pop_back();
}
}
if (interpolating || sc.chNext != '}') {
const int state = sc.state;
sc.SetState(SCE_PY_OPERATOR2);
sc.ForwardSetState(state);
fstringPart = FormattedStringPart::None;
continue;
}
}
Expand Down

0 comments on commit 85c9f0c

Please sign in to comment.