#899 Toggle line commentation does not keep caret position.

General (289)
Van de Bugger

Let us assume "foo.c" file is being editing. Underscore denotes a space, bar -- the caret position.

line 1
line 2|

I expected "Toggle line commentation" operation will comment and uncomment a line, keeping the caret position intact (relatively to surrounding text, if possible). In my configuration this operation assigned to Ctrl+~, and comment line marker is set to "~". Pressing Ctrl+~ for the first time gives

line 1
//~_line 2|

Pressing Ctrl+grave again reverts the change:

line 1
line 2|

Everything is ok. Now let us comment the line again and move the caret to the left:

line 1
//~|_line 2

and uncomment the line:

line 1|
line 2

Line is uncommented, but the caret is moved to the end of the previous line. I would expect the caret will stay in the second line:

line 1
|line 2

One more similar test:

line 1
|//~_line 2

Uncommeting the line gives:

lin|e 1
line 2

If the second line is indented and the caret is within leading spaces:

line 1
__|__line 2

Commenting the line gives:

line 1
____//|~_line 2

I would expect the caret stays in the same position within the leading spaces:

line 1
__|__//~_line 2


    • priority: 5 --> 3
    • milestone: 3508874 -->
    • status: open --> open-accepted
    • assigned_to: nobody --> colombanw
  • Now fixed in Git, thanks for reporting.

    • milestone: --> v1.23
    • status: open-accepted --> closed-fixed