diff options
-rw-r--r-- | doc/ScintillaHistory.html | 12 | ||||
-rw-r--r-- | lexers/LexBash.cxx | 42 |
2 files changed, 49 insertions, 5 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 6a6ab5ec5..e03a8b344 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -513,16 +513,14 @@ </li> <li> Bash lexer flags incomplete here doc delimiters as syntax errors. - <a href="http://sourceforge.net/p/scintilla/bugs/1789/">Bug #1789</a>. + <a href="http://sourceforge.net/p/scintilla/bugs/1789/">Bug #1789</a>.<br /> + Support added for using '#' in non-comment ways as is possible with zsh. + <a href="http://sourceforge.net/p/scintilla/bugs/1794/">Bug #1794</a>. </li> <li> Errorlist lexer highlights warning messages from the Microsoft linker. </li> <li> - On Windows, Scintilla no longer uses a .DEF file during linking as it duplicates - source code directives. - </li> - <li> Lua lexer includes '&' and '|' bitwise operators for Lua 5.3. <a href="http://sourceforge.net/p/scintilla/bugs/1790/">Bug #1790</a>. </li> @@ -558,6 +556,10 @@ to the end of the cluster making it easier to understand editing actions. </li> <li> + On Windows, Scintilla no longer uses a .DEF file during linking as it duplicates + source code directives. + </li> + <li> On GTK+ and Qt, Korean input by word fixed. </li> <li> diff --git a/lexers/LexBash.cxx b/lexers/LexBash.cxx index f9d4d2a25..09dd29650 100644 --- a/lexers/LexBash.cxx +++ b/lexers/LexBash.cxx @@ -96,6 +96,19 @@ static int opposite(int ch) { return ch; } +static int GlobScan(StyleContext &sc) { + // forward scan for a glob-like (...), no whitespace allowed + int c, sLen = 0; + while ((c = sc.GetRelativeCharacter(++sLen)) != 0) { + if (IsASpace(c)) { + return 0; + } else if (c == ')') { + return sLen; + } + } + return 0; +} + static void ColouriseBashDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { @@ -337,6 +350,8 @@ static void ColouriseBashDoc(Sci_PositionU startPos, Sci_Position length, int in sc.ForwardSetState(SCE_SH_DEFAULT); } else if (!setWord.Contains(sc.ch)) { sc.SetState(SCE_SH_DEFAULT); + } else if (cmdState == BASH_CMD_ARITH && !setWordStart.Contains(sc.ch)) { + sc.SetState(SCE_SH_DEFAULT); } break; case SCE_SH_NUMBER: @@ -628,6 +643,24 @@ static void ColouriseBashDoc(Sci_PositionU startPos, Sci_Position length, int in } else { sc.SetState(SCE_SH_WORD); } + // handle some zsh features within arithmetic expressions only + if (cmdState == BASH_CMD_ARITH) { + if (sc.chPrev == '[') { // [#8] [##8] output digit setting + sc.SetState(SCE_SH_WORD); + if (sc.chNext == '#') { + sc.Forward(); + } + } else if (sc.chNext == '#' && !IsASpace(sc.GetRelative(2))) { // ##a + sc.SetState(SCE_SH_IDENTIFIER); + sc.Forward(2); + } else if (sc.Match("##^") && IsUpperCase(sc.GetRelative(3))) { // ##^A + sc.SetState(SCE_SH_IDENTIFIER); + sc.Forward(3); + continue; + } else if (setWordStart.Contains(sc.chNext)) { + sc.SetState(SCE_SH_IDENTIFIER); + } + } } else if (sc.ch == '\"') { sc.SetState(SCE_SH_STRING); QuoteStack.Start(sc.ch, BASH_DELIM_STRING); @@ -681,6 +714,15 @@ static void ColouriseBashDoc(Sci_PositionU startPos, Sci_Position length, int in char s[10]; bool isCmdDelim = false; sc.SetState(SCE_SH_OPERATOR); + // globs have no whitespace, do not appear in arithmetic expressions + if (cmdState != BASH_CMD_ARITH && sc.ch == '(' && sc.chNext != '(') { + int i = GlobScan(sc); + if (i > 1) { + sc.SetState(SCE_SH_IDENTIFIER); + sc.Forward(i); + continue; + } + } // handle opening delimiters for test/arithmetic expressions - ((,[[,[ if (cmdState == BASH_CMD_START || cmdState == BASH_CMD_BODY) { |