aboutsummaryrefslogtreecommitdiffhomepage
path: root/lexers/LexPython.cxx
diff options
context:
space:
mode:
authorJohn Ehresman <unknown>2016-03-16 10:30:22 +1100
committerJohn Ehresman <unknown>2016-03-16 10:30:22 +1100
commit263292431cc87c6941b7474ddee8baa111bde6bf (patch)
tree78c404d06986087e343aa6563d422f6c2bf3efd1 /lexers/LexPython.cxx
parent54997bcaaccc3abc35b48fdbb2cbadb8a2add964 (diff)
downloadscintilla-mirror-263292431cc87c6941b7474ddee8baa111bde6bf.tar.gz
Support Python 3.5 '@' operator.
Diffstat (limited to 'lexers/LexPython.cxx')
-rw-r--r--lexers/LexPython.cxx16
1 files changed, 15 insertions, 1 deletions
diff --git a/lexers/LexPython.cxx b/lexers/LexPython.cxx
index 7cd3bc8de..19dd0ca3b 100644
--- a/lexers/LexPython.cxx
+++ b/lexers/LexPython.cxx
@@ -117,6 +117,17 @@ inline bool IsAWordStart(int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '_');
}
+static bool IsFirstNonWhitespace(Sci_Position pos, Accessor &styler) {
+ Sci_Position line = styler.GetLine(pos);
+ Sci_Position start_pos = styler.LineStart(line);
+ for (Sci_Position i = start_pos; i < pos; i++) {
+ char ch = styler[i];
+ if (!(ch == ' ' || ch == '\t'))
+ return false;
+ }
+ return true;
+}
+
// Options used for LexerPython
struct OptionsPython {
int whingeLevel;
@@ -560,7 +571,10 @@ void SCI_METHOD LexerPython::Lex(Sci_PositionU startPos, Sci_Position length, in
} else if (sc.ch == '#') {
sc.SetState(sc.chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE);
} else if (sc.ch == '@') {
- sc.SetState(SCE_P_DECORATOR);
+ if (IsFirstNonWhitespace(sc.currentPos, styler))
+ sc.SetState(SCE_P_DECORATOR);
+ else
+ sc.SetState(SCE_P_OPERATOR);
} else if (IsPyStringStart(sc.ch, sc.chNext, sc.GetRelative(2), allowedLiterals)) {
Sci_PositionU nextIndex = 0;
sc.SetState(GetPyStringState(styler, sc.currentPos, &nextIndex, allowedLiterals));