notepad-plus-plus
notepad-plus-plus copied to clipboard
Yaml syntax highlighting does not respect empty lines in blocks of text
Description of the Issue
Yaml syntax highlighting does not respect empty lines in blocks of text. An empty line is not considered to have lower indentation than the previous line, text blocks will continue across them.
Steps to Reproduce the Issue
Write yaml like this:
my_yaml_block: |
This block is text
even if the line above is empty
these two lines below should also be highlighted as text.
with row 2 empty
Expected Behavior
All lines above are highlighted as text
Actual Behavior
Rows 3 and 4 will be default-highlighted
Debug Information
Notepad++ v7.8.9 (64-bit) Build time : Jul 15 2020 - 20:31:49 Admin mode : OFF Local Conf mode : ON OS Name : Windows 10 Enterprise (64-bit) OS Version : 1809 OS Build : 17763.1457 Current ANSI codepage : 1252 Plugins : GitSCM.dll MarkdownViewerPlusPlus.dll mimeTools.dll NppConverter.dll NppExport.dll NPPJSONViewer.dll NppXmlTreeviewPlugin.dll XMLTools.dll
Suggest something similar to
diff --git a/scintilla/lexers/LexYAML.cxx b/scintilla/lexers/LexYAML.cxx
index 3002030d..e5a4cdfa 100644
--- a/scintilla/lexers/LexYAML.cxx
+++ b/scintilla/lexers/LexYAML.cxx
@@ -88,9 +88,11 @@ static void ColouriseYAMLLine(
if ((parentLineState&YAML_STATE_MASK) == YAML_STATE_TEXT || (parentLineState&YAML_STATE_MASK) == YAML_STATE_TEXT_PARENT) {
unsigned int parentIndentAmount = parentLineState&(~YAML_STATE_MASK);
- if (indentAmount > parentIndentAmount) {
+ if (lineBuffer[indentAmount] == '\0' || indentAmount > parentIndentAmount) {
styler.SetLineState(currentLine, YAML_STATE_TEXT | parentIndentAmount);
- styler.ColourTo(endPos, SCE_YAML_TEXT);
+ if (indentAmount > parentIndentAmount) {
+ styler.ColourTo(endPos, SCE_YAML_TEXT);
+ }
return;
}
}
And I'd be happy to write a pull request with it if you believe its correct.
You can directly write to Scintilla.
@phoenikz
What @ArkadiuszMichalski means is that this is a problem with Scintilla, not Notepad++. Thus there is nothing Notepad++ can do to fix it.
https://sourceforge.net/p/scintilla/bugs/2218/
@donho @sasumner
I can confirm this is NOT fixed in Notepad++ 7.9.3 Unicode Debug using the latest Scintilla 4.4.6 DLL. There are no YAML related updates to Scintilla change log since 3.7.5. Note that putting a single space on the blank line colors the text block correctly in both current 4.2.0 and 4.4.6.
Cheers.
See #15273. Issue still exists with N++ v8.6.7.
There is a related issue posted at https://github.com/notepad-plus-plus/notepad-plus-plus/issues/15273#issuecomment-2162139675, which I will repost here.
- run: |
# first line of shell script
# last line of shell script
if: condition for running step
[
{
"run": "# first line of shell script\n# last line of shell script\n",
"if": "condition for running step"
}
]
Notepad++ fails to highlight it correctly.
VS Code correctly highlights it.
GitHub actually highlights this correctly, even though GitHub fails when there is a blank line in the string.
Reported again to Lexilla https://github.com/ScintillaOrg/lexilla/issues/326