diff options
author | Kein-Hong Man <unknown> | 2017-05-08 08:30:18 +1000 |
---|---|---|
committer | Kein-Hong Man <unknown> | 2017-05-08 08:30:18 +1000 |
commit | e42c4cfeda5fe1a71f8402cf8f64704c976ee8ba (patch) | |
tree | 1db1d8d84bb6266d0f1836316303f34142baeecd | |
parent | 0d54ce0341ead232ec9c924bb6cee9bebf56c1f9 (diff) | |
download | scintilla-mirror-e42c4cfeda5fe1a71f8402cf8f64704c976ee8ba.tar.gz |
Bug [#1944]. Recognize strings in lists in more cases.
-rw-r--r-- | doc/ScintillaHistory.html | 4 | ||||
-rw-r--r-- | lexers/LexBash.cxx | 17 |
2 files changed, 19 insertions, 2 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 925f7f5dc..d2a1073e0 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -541,6 +541,10 @@ Updated case conversion and character categories to Unicode 9. </li> <li> + The Bash lexer recognizes strings in lists in more cases. + <a href="http://sourceforge.net/p/scintilla/bugs/1944/">Bug #1944</a>. + </li> + <li> The Fortran lexer recognizes a preprocessor line after a line continuation &. <a href="http://sourceforge.net/p/scintilla/bugs/1935/">Bug #1935</a>. </li> diff --git a/lexers/LexBash.cxx b/lexers/LexBash.cxx index af8507d7d..9c02c2897 100644 --- a/lexers/LexBash.cxx +++ b/lexers/LexBash.cxx @@ -97,13 +97,26 @@ static int opposite(int ch) { } static int GlobScan(StyleContext &sc) { - // forward scan for a glob-like (...), no whitespace allowed + // forward scan for zsh globs, disambiguate versus bash arrays + // complex expressions may still fail, e.g. unbalanced () '' "" etc int c, sLen = 0; + int pCount = 0; + int hash = 0; while ((c = sc.GetRelativeCharacter(++sLen)) != 0) { if (IsASpace(c)) { return 0; + } else if (c == '\'' || c == '\"') { + if (hash != 2) return 0; + } else if (c == '#' && hash == 0) { + hash = (sLen == 1) ? 2:1; + } else if (c == '(') { + pCount++; } else if (c == ')') { - return sLen; + if (pCount == 0) { + if (hash) return sLen; + return 0; + } + pCount--; } } return 0; |