Bug 436480

Summary: Deleting folded lines does not remove code folding marker
Product: [Frameworks and Libraries] frameworks-ktexteditor Reporter: Kishore Gopalakrishnan <kishore96>
Component: generalAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: 5.81.0   
Target Milestone: ---   
Platform: Other   
OS: Other   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Screenshot showing observed result after step 4

Description Kishore Gopalakrishnan 2021-05-02 05:16:29 UTC
Created attachment 138072 [details]
Screenshot showing observed result after step 4

SUMMARY
When you delete a set of folded lines, the code folding marker is wrongly shown even if the entire folded environment is removed.

STEPS TO REPRODUCE
1. Create a file with a foldable environment (e.g., the following file, blah.py; numbers like L1, L2, ... at the beginning denote line numbers). You will have to save the file.
```
L1 | print("pre-blah")
L2 |
L3 | def f(x):
L4 | 	a = 1+2
L5 | 	b = 2+3
L6 | 	return a+b
L7 | 
L8 | print("blah")
```
2. Fold the definition of f(x) by clicking on the code folding arrow that appears in L3.
3. Select lines L2-L7 with the mouse
4. Press Ctrl+K (to delete lines)

OBSERVED RESULTS
A 'folded code' marker is shown on the line containing the second print statement (see attached screenshot). Clicking on the code folding marker makes it disappear.

EXPECTED RESULTS
If a folded block of code is deleted, the code folding marker should also be removed immediately.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.21.4
KDE Frameworks Version: 5.81.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
I was able to reproduce this in both Kile and Kate, so I am reporting this under ktexteditor.
Comment 1 Bug Janitor Service 2022-08-10 16:48:44 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/399
Comment 2 Christoph Cullmann 2022-08-10 20:07:54 UTC
Git commit 28d9cbc32fdda5ced60626c0487dd69c7f5a8b49 by Christoph Cullmann, on behalf of Waqar Ahmed.
Committed on 10/08/2022 at 20:02.
Pushed by cullmann into branch 'master'.

Update folding ranges on text modification

M  +28   -0    src/buffer/katetextfolding.cpp
M  +2    -0    src/buffer/katetextfolding.h
M  +1    -0    src/view/kateview.cpp

https://invent.kde.org/frameworks/ktexteditor/commit/28d9cbc32fdda5ced60626c0487dd69c7f5a8b49