diff options
-rw-r--r-- | doc/ScintillaHistory.html | 4 | ||||
-rw-r--r-- | lexers/LexYAML.cxx | 22 |
2 files changed, 22 insertions, 4 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 404ffa16d..b5f9fdf07 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -545,6 +545,10 @@ <a href="http://sourceforge.net/p/scintilla/feature-requests/1143/">Feature #1143.</a> </li> <li> + The YAML lexer recognizes inline comments. + <a href="http://sourceforge.net/p/scintilla/bugs/1660/">Bug #1660</a>. + </li> + <li> Fix caret position after left or right movement with rectangular selection. <a href="http://sourceforge.net/p/scintilla/bugs/1861/">Bug #1861</a>. </li> diff --git a/lexers/LexYAML.cxx b/lexers/LexYAML.cxx index 5f94215d1..e420d9d79 100644 --- a/lexers/LexYAML.cxx +++ b/lexers/LexYAML.cxx @@ -148,16 +148,30 @@ static void ColouriseYAMLLine( styler.ColourTo(endPos, SCE_YAML_KEYWORD); return; } else { + Sci_PositionU startComment = i; + bInQuotes = false; + while (startComment < lengthLine) { // Comment must be space padded + if (lineBuffer[startComment] == '\'' || lineBuffer[startComment] == '\"') + bInQuotes = !bInQuotes; + if (lineBuffer[startComment] == '#' && isspacechar(lineBuffer[startComment - 1]) && !bInQuotes) + break; + startComment++; + } Sci_PositionU i2 = i; - while ((i < lengthLine) && lineBuffer[i]) { - if (!(IsASCII(lineBuffer[i]) && isdigit(lineBuffer[i])) && lineBuffer[i] != '-' && lineBuffer[i] != '.' && lineBuffer[i] != ',') { - styler.ColourTo(endPos, SCE_YAML_DEFAULT); + while ((i < startComment) && lineBuffer[i]) { + if (!(IsASCII(lineBuffer[i]) && isdigit(lineBuffer[i])) && lineBuffer[i] != '-' + && lineBuffer[i] != '.' && lineBuffer[i] != ',' && lineBuffer[i] != ' ') { + styler.ColourTo(startLine + startComment - 1, SCE_YAML_DEFAULT); + if (startComment < lengthLine) + styler.ColourTo(endPos, SCE_YAML_COMMENT); return; } i++; } if (i > i2) { - styler.ColourTo(endPos, SCE_YAML_NUMBER); + styler.ColourTo(startLine + startComment - 1, SCE_YAML_NUMBER); + if (startComment < lengthLine) + styler.ColourTo(endPos, SCE_YAML_COMMENT); return; } } |