eranif / codelite

A multi purpose IDE specialized in C/C++/Rust/Python/PHP and Node.js. Written in C++
https://codelite.org
GNU General Public License v2.0
2.09k stars 448 forks source link

[Bug]: "Comment Line" command uncomments when it should comment #3315

Open yunkot opened 4 months ago

yunkot commented 4 months ago

What happened?

Consider the following code:

// hello world
void myFunc(void)
{
  // some code
  callOtherFunc();
}

If you select aforementioned block and press "Ctrl + /", or use menu Edit - Comment - Comment Line, then an expected action would be to comment out the whole block, whereas CodeLite will actually uncomment the two comment lines. A workaround is to remove one of "/" in the first line before invoking the command, or make sure to select code block starting at "v" in second line. The workaround doesn't help if a code block is sufficiently large and includes both commented and non-commented lines.

It looks like CodeLite decides on whether to "comment" or "uncomment" based on the characters from the first line, which would work only for a single line of code, but not multi-line code. From practical standpoint, it would be correct to check all the lines in the selected block and if there are any lines that are not commented, then the operation should be to "comment", otherwise the operation should be "uncomment".

Version

Self-compiled from GitHub, commit: 6eb52aaff1bb3b999001fbbf56f38bc844000c41

Operating system

Arch Linux / Gnome