diff options
author | Colomban Wendling <ban@herbesfolles.org> | 2014-12-12 18:47:31 +0100 |
---|---|---|
committer | Colomban Wendling <ban@herbesfolles.org> | 2014-12-12 18:47:31 +0100 |
commit | 0eb57695d1691b5e878ca4c3cd3ec56a8503fc23 (patch) | |
tree | 86b3847c726f70e6e3806b718fdfdc7134bf0470 | |
parent | 8b783ca2f2bb955861bbada959ab5bae19d9a4ca (diff) | |
download | scintilla-mirror-0eb57695d1691b5e878ca4c3cd3ec56a8503fc23.tar.gz |
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
-rw-r--r-- | lexers/LexBash.cxx | 9 |
1 files 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)) && |