codelite icon indicating copy to clipboard operation
codelite copied to clipboard

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

Open yunkot opened this issue 4 months ago • 0 comments

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

yunkot avatar Feb 26 '24 23:02 yunkot