Bug 456534 - "Toggle Comments" Tool Sometimes indefinitely adds comment symbols in python on each press
Summary: "Toggle Comments" Tool Sometimes indefinitely adds comment symbols in python ...
Status: RESOLVED DUPLICATE of bug 451471
Alias: None
Product: kate
Classification: Applications
Component: general (other bugs)
Version First Reported In: 22.04.2
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-07-10 00:36 UTC by Joe Shef
Modified: 2022-07-10 10:34 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joe Shef 2022-07-10 00:36:33 UTC
SUMMARY
Testing a python script, I attempted to toggle comments on a few blocks of code, the toggle instead added indefinitely to the existing comment symbol (not automatically, each press  adds a new symbol)

STEPS TO REPRODUCE
1. Create a basic script, here's an example:

def main():
    print("hello world")
    if 1 == 1:
        print("yes")
    print("after")

if __name__ = '__main__':
    main()

2. Highlight portions you wish to comment out, hit the toggle comment shortcut (default is ctrl + /), then hit it again, if multiple blocks of code are highlighted, like both the function and the if statement at the bottom, it seems to add more comment characters instead of un-commenting what you just commented (goes for existing comments as well)

OBSERVED RESULT
Additional comment symbols added 

EXPECTED RESULT
Toggle between a line being commented and not (adding/removing symbol as needed)

SOFTWARE/OS VERSIONS
Linux: EndeavourOS, Gnome DE (wayland support :/ )
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
I attempted to find where this code is in gitlab, but couldn't seem to find the lines that were for toggle comment as the only things mentioning "toggle comment" exactly were some .docbook files - so am not able to determine the issue myself. **I will happily dive into the code as well if someone can point me to the right spot to look**
Comment 1 Alain Laporte 2022-07-10 08:20:46 UTC
The "toggle comment" code is probably in KTextEditor => https://lxr.kde.org/source/frameworks/ktexteditor/src/view/kateview.cpp

You can use LXR to search in all the KDE code => https://lxr.kde.org/search?%21v=kf5-qt5&_filestring=&_string=%22toggle+comment%22 (beware, this link is slow to produce result because it search a string in the code).
Comment 2 Alain Laporte 2022-07-10 08:34:13 UTC
I have tested on the version provided by Kubuntu 22.04 (Kate 21.12.3 and KDE Frameworks 5.92) and I reproduce your issue (the behavior is the same like we comment the line with Ctrl + D).

But on the master, I don't reproduce the issue (toggle comment works as expected). Do you confirm that?
Comment 3 Alain Laporte 2022-07-10 08:40:54 UTC
Seems a duplicate of https://bugs.kde.org/show_bug.cgi?id=451471 (which have been fixed in KDE Frameworks 5.93).
Comment 4 Waqar Ahmed 2022-07-10 10:34:32 UTC

*** This bug has been marked as a duplicate of bug 451471 ***