diff options
-rw-r--r-- | doc/ScintillaHistory.html | 4 | ||||
-rw-r--r-- | lexers/LexPython.cxx | 16 |
2 files changed, 19 insertions, 1 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 2f06203e1..d1331ab10 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -503,6 +503,10 @@ Released 18 May 2016. </li> <li> + The Python lexer treats '@' as an operator except when it is the first visible character on a line. + This is for Python 3.5. + </li> + <li> SciTE bug fixed with exported HTML where extra line shown. <a href="http://sourceforge.net/p/scintilla/bugs/1816/">Bug #1816</a>. </li> 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)); |