zufuliu / notepad4

Notepad4 (Notepad2⨯2, Notepad2++) is a light-weight Scintilla based text editor for Windows with syntax highlighting, code folding, auto-completion and API list for many programming languages and documents, bundled with file browser plugin matepath.
Other
2.42k stars 174 forks source link

Unusual behaviour of markdown syntax highlighting #801

Closed bluenlive closed 1 month ago

bluenlive commented 1 month ago

If you open the attached file with Notepad 4, you can see the screen like below. README.md n1

If you place the cursor on the 8th line, press Enter and type test text, you will see this screen. n2

If you save this file and open it again with Notepad 4, you will see this screen. You can see that it's different than before we saved it. n3

If I select and delete line 8 from the beginning to the end of line 9, I get a screen like this. It's the same file I opened, but it's displayed differently. n4

If you try a similar operation with copy-paste, you'll see another strange result.

I've captured the Korean version, but stock Notepad4 shows the same result.

zufuliu commented 1 month ago

Fixed by f44acceed9f89e0f1991baa28eeca5805e38f310.

bluenlive commented 1 month ago

Thanks for the quick fix. However, I don't think it's completely fixed.

If I type enter at the beginning of line 9 of this file (which is the same file as above) and then type test text on line 9 again, test.md n1

the error still exists, showing the same as before. n2

P.S., since the notepad2 mod is being renamed to notepad4, I've posted a bunch of stuff I've been thinking about. Thanks for your attention.

zufuliu commented 1 month ago

Following is a quick fix:

diff --git a/scintilla/lexers/LexMarkdown.cxx b/scintilla/lexers/LexMarkdown.cxx
index 96c2d383..6d2eeea7 100644
--- a/scintilla/lexers/LexMarkdown.cxx
+++ b/scintilla/lexers/LexMarkdown.cxx
@@ -1865,7 +1865,7 @@ void ColouriseMarkdownDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int in
                        initStyle = (startPos == 0) ? 0 : styler.StyleAt(startPos - 1);
                }
                if (startPos != 0) {
-                       BacktrackToStart(styler, LineStateNestedStateLine, startPos, lengthDoc, initStyle);
+                       BacktrackToStart(styler, LineStateNestedStateLine | LineStateEmptyLine, startPos, lengthDoc, initStyle);
                }
        }
zufuliu commented 1 month ago

Should be full fixed by f0b9e1aba513c1fd94dcaf2ba7f0f46b2b9e199c.

bluenlive commented 1 month ago

It works well! Thank you for your work!!!