Bug 441278

Summary: folding bug when editing markdown
Product: [Applications] kate Reporter: ghands
Component: foldingAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: 21.04.0   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Unexpected Folding in Markdown
Source Markdown Code

Description ghands 2021-08-21 09:05:59 UTC
SUMMARY

When folding markdown code according to the level of title, the higher level of title is folded into the lower level

STEPS TO REPRODUCE
1. Input markdown code like ``# Hello \n ## World \n # Bye \n ## Evil''
2. Folding the line ``## World'', you will find the ``# Bye'' is folded.

OBSERVED RESULT
(There is no downward in ASCII, I use ^ to mean the unfolded line)
^ # Hello
> ## World
^ ## Evil

EXPECTED RESULT
(There is no downward in ASCII, I use ^ to mean the unfolded line)
^ # Hello
> ## World
^ # Bye
^ ## Evil

SOFTWARE/OS VERSIONS
Windows: Windows 10 20H2
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 ghands 2021-08-21 09:08:27 UTC
Created attachment 140903 [details]
Unexpected Folding in Markdown
Comment 2 ghands 2021-08-21 09:08:50 UTC
Created attachment 140904 [details]
Source Markdown Code
Comment 3 Bug Janitor Service 2021-08-31 14:38:15 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/syntax-highlighting/-/merge_requests/251
Comment 4 Jan Paul Batrina 2021-09-01 12:54:37 UTC
Git commit a49918bbce6edb8c03c28435787c7e4a0a732bf0 by Jan Paul Batrina.
Committed on 31/08/2021 at 14:34.
Pushed by cullmann into branch 'master'.

markdown.xml: End nested sub-headers fold regions when parent header is closed

e.g.

 # H1
 ## H2
 ### H3
 # H1 <-- All headers above should end here

This is currently done using a hack, visible to users
since part of the next header is included in the
previous region (e.g. [### H3\n# H]1 is how the region
above will be marked).

In the future, a better solution would be to provide a mechanism
to close multiple folding regions with a single rule.

M  +211  -199  autotests/folding/test.markdown.fold
M  +56   -44   autotests/html/test.markdown.dark.html
M  +56   -44   autotests/html/test.markdown.html
M  +12   -0    autotests/input/test.markdown
M  +56   -44   autotests/reference/test.markdown.ref
M  +25   -6    data/syntax/markdown.xml

https://invent.kde.org/frameworks/syntax-highlighting/commit/a49918bbce6edb8c03c28435787c7e4a0a732bf0