From e42c4cfeda5fe1a71f8402cf8f64704c976ee8ba Mon Sep 17 00:00:00 2001 From: Kein-Hong Man Date: Mon, 8 May 2017 08:30:18 +1000 Subject: Bug [#1944]. Recognize strings in lists in more cases. --- lexers/LexBash.cxx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'lexers') 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; -- cgit v1.2.3