From fc7ac54d5936008e1e2db8f490ae105e4acebfbb Mon Sep 17 00:00:00 2001 From: Jim Pattee Date: Mon, 10 Apr 2017 08:14:34 +1000 Subject: Bug [#1931]. Recognize comments in more situations and treat "..." like "---". --- doc/ScintillaHistory.html | 5 +++++ lexers/LexYAML.cxx | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 7caf33425..0cca9f7a0 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -543,6 +543,11 @@ The Python lexer recognizes identifiers more accurately when they include non-ASCII characters.
  • + The YAML lexer recognizes comments in more situations and styles a + "..." line like a "---" line. + Bug #1931. +
  • +
  • On Cocoa, the autocompletion is 4 pixels wider to avoid text truncation.
  • diff --git a/lexers/LexYAML.cxx b/lexers/LexYAML.cxx index 9f28bb843..3709538b7 100644 --- a/lexers/LexYAML.cxx +++ b/lexers/LexYAML.cxx @@ -98,7 +98,7 @@ static void ColouriseYAMLLine( } } styler.SetLineState(currentLine, 0); - if (strncmp(lineBuffer, "---", 3) == 0) { // Document marker + if (strncmp(lineBuffer, "---", 3) == 0 || strncmp(lineBuffer, "...", 3) == 0) { // Document marker styler.SetLineState(currentLine, YAML_STATE_DOCUMENT); styler.ColourTo(endPos, SCE_YAML_DOCUMENT); return; @@ -119,6 +119,10 @@ static void ColouriseYAMLLine( while (i < lengthLine) { if (lineBuffer[i] == '\'' || lineBuffer[i] == '\"') { bInQuotes = !bInQuotes; + } else if (lineBuffer[i] == '#' && isspacechar(lineBuffer[i - 1]) && !bInQuotes) { + styler.ColourTo(startLine + i - 1, SCE_YAML_DEFAULT); + styler.ColourTo(endPos, SCE_YAML_COMMENT); + return; } else if (lineBuffer[i] == ':' && !bInQuotes) { styler.ColourTo(startLine + i - 1, SCE_YAML_IDENTIFIER); styler.ColourTo(startLine + i, SCE_YAML_OPERATOR); -- cgit v1.2.3