Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yaml syntax highlighting does not respect empty lines in blocks of text #9038

Open
phoenikz opened this issue Oct 20, 2020 · 7 comments
Open
Labels
lexilla dependent Can't be considered for N++ implementation unless/until Lexiilla changes scintilla dependent Can't be considered for N++ implementation unless/until Scintilla changes

Comments

@phoenikz
Copy link

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

@phoenikz
Copy link
Author

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.

@ArkadiuszMichalski
Copy link
Contributor

You can directly write to Scintilla.

@sasumner sasumner added the scintilla dependent Can't be considered for N++ implementation unless/until Scintilla changes label Oct 20, 2020
@sasumner
Copy link
Contributor

@phoenikz

What @ArkadiuszMichalski means is that this is a problem with Scintilla, not Notepad++.
Thus there is nothing Notepad++ can do to fix it.

@phoenikz
Copy link
Author

https://sourceforge.net/p/scintilla/bugs/2218/

@vinsworldcom
Copy link

@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.

@chcg
Copy link
Contributor

chcg commented Jun 12, 2024

See #15273. Issue still exists with N++ v8.6.7.

@theonlypwner
Copy link

There is a related issue posted at #15273 (comment), 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.

image

VS Code correctly highlights it.

image

GitHub actually highlights this correctly, even though GitHub fails when there is a blank line in the string.

image

@ArkadiuszMichalski ArkadiuszMichalski added the lexilla dependent Can't be considered for N++ implementation unless/until Lexiilla changes label Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lexilla dependent Can't be considered for N++ implementation unless/until Lexiilla changes scintilla dependent Can't be considered for N++ implementation unless/until Scintilla changes
Projects
None yet
Development

No branches or pull requests

6 participants