Bug 458126 - Toggling comments on selected text that is separated with empty lines, works one way
Summary: Toggling comments on selected text that is separated with empty lines, works ...
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: general (show other bugs)
Version: 22.04.1
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-21 06:30 UTC by Maciej Lebiest
Modified: 2022-08-21 17:15 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Maciej Lebiest 2022-08-21 06:30:13 UTC
SUMMARY
So the problem is with toggling comment with ctrl+/ shortcut.
If selected text contains empty lines, then this shortcut will only add more levels of comment (in python adding more # )
, but it will not add comment on the empty line, nor will remove comment if whole text (except these empty lines) is already commented.

STEPS TO REPRODUCE
1. Create .yml file containing yaml config with empty line:

test:
    test2:
        - whatever

another:
    another2: hello


2. select this whole text with mouse dragging over it
3. press ctrl+/ to comment/uncomment selected text multiple times

OBSERVED RESULT
Additional layers of comment are added to the text:
######test:
    ######test2:
        ######- whatever

######another:
    ######another2: hello

EXPECTED RESULT
Only one level of comment is made, and then removed with every second toggling.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Fedora 36
KDE Plasma Version: 5.25.4
KDE Frameworks Version: 5.97.0
Qt Version: 5.15.5

ADDITIONAL INFORMATION
If instead of selecting text with mouse dragging, i put on each line multicursor (leftAlt+click) and then use toogling comments, then it works as expected.
Comment 1 Bug Janitor Service 2022-08-21 15:36:18 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/407
Comment 2 Christoph Cullmann 2022-08-21 17:15:18 UTC
Git commit 89c0b14fec9e42d12c1fcc5e60b5defece28a3e7 by Christoph Cullmann, on behalf of Waqar Ahmed.
Committed on 21/08/2022 at 17:09.
Pushed by cullmann into branch 'master'.

Fix toggle comment with empty line in selection

M  +14   -0    autotests/src/katedocument_test.cpp
M  +5    -1    src/document/katedocument.cpp

https://invent.kde.org/frameworks/ktexteditor/commit/89c0b14fec9e42d12c1fcc5e60b5defece28a3e7