Sublime Forum

Buggy 'Toggle Comment' Behavior

#1

Paste the following code into a cpp-file.

/*1234567890*/
int a1234567890;

Now select text from start of the line with the block comment…

  • … to the 1 (inclusive) inside the block comment, then toggle line comment. -> Correctly toggles line comment.
  • … to the 2 (inclusive) inside the block comment, then toggle line comment. -> Incorrectly toggles the existing block comment.
  • … to the 3 (inclusive) inside the variable name, then toggle line comment. -> Incorrectly toggles the existing block comment.
  • … to the 4 (inclusive) inside the variable name, then toggle line comment. -> Correctly toggles line comment.

This causes block comments to be practically unusable for my workflow. I’ll try to comment out a chunk of code, but most of the time it’ll instead toggle an existing block comment somewhere inside the selection.

Tested on Windows 7 and 10 in:
sublime_text_build_4121_x64
sublime_text_build_4126_x64

Same issue in js-files.

When logging commands, it always shows toggle_comment {"block": false}.

A fix would be very much appreciated. Let me know if you need more info.

0 Likes

#2

you might find it’s already been fixed in a Dev build

0 Likes

#3

I tried the proposed workaround, but it seems the GitHub thread is about a different issue?

Now knowing where to look though, I solved it by changing this line

if self.remove_block_comment(self.view, edit, comment_data, region):

to this

if block and self.remove_block_comment(self.view, edit, comment_data, region):

in that same file Default/comment.py

Edit: Note though that the actual problem seems to be somewhere else, as there is also inconsistent behavior when toggling block comments while text selection partially overlaps an existing block comment, depending on where the selection starts/ends.

0 Likes

#4

I can’t reproduce this in build 4134 - this seems to be fixed already.

0 Likes