From 0eb57695d1691b5e878ca4c3cd3ec56a8503fc23 Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Fri, 12 Dec 2014 18:47:31 +0100 Subject: LexBash: Don't allow spaces between `<<` and `-` in a heredoc operator `<<-` is an operator of itself, not two separate tokens `<<` and `-`. This fixes handling of delimiters starting with `-`, like this: cat<< -EOF ... -EOF --- lexers/LexBash.cxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lexers/LexBash.cxx b/lexers/LexBash.cxx index 3ebba8911..0df343cd2 100644 --- a/lexers/LexBash.cxx +++ b/lexers/LexBash.cxx @@ -419,8 +419,6 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle, sc.Forward(); HereDoc.Quoted = true; HereDoc.State = 1; - } else if (!HereDoc.Indent && sc.chNext == '-') { // <<- indent case - HereDoc.Indent = true; } else if (setHereDoc.Contains(sc.chNext)) { // an unquoted here-doc delimiter, no special handling // TODO check what exactly bash considers part of the delim @@ -672,7 +670,12 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle, } else if (sc.Match('<', '<')) { sc.SetState(SCE_SH_HERE_DELIM); HereDoc.State = 0; - HereDoc.Indent = false; + if (sc.GetRelative(2) == '-') { // <<- indent case + HereDoc.Indent = true; + sc.Forward(); + } else { + HereDoc.Indent = false; + } } else if (sc.ch == '-' && // one-char file test operators setSingleCharOp.Contains(sc.chNext) && !setWord.Contains(sc.GetRelative(2)) && -- cgit v1.2.3