aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJim Pattee <unknown>2016-09-23 18:12:22 +1000
committerJim Pattee <unknown>2016-09-23 18:12:22 +1000
commiteadbd5b47a18280a54d6223aca2383cd04d6007a (patch)
treeefd8e8ce60fed89c7e2247ee3f89630f79ba62a7
parentfdb8953cdffa47ff9f13f1cc173e1cb2df191019 (diff)
downloadscintilla-mirror-eadbd5b47a18280a54d6223aca2383cd04d6007a.tar.gz
Recognize inline comments in YAML.
-rw-r--r--doc/ScintillaHistory.html4
-rw-r--r--lexers/LexYAML.cxx22
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;
}
}