Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[comment.py] Toggle Comment line bug #691

Closed
TheClams opened this issue Nov 15, 2016 · 2 comments
Closed

[comment.py] Toggle Comment line bug #691

TheClams opened this issue Nov 15, 2016 · 2 comments

Comments

@TheClams
Copy link
Contributor

The toggle comment can sometime behave strangely if there is block comment embedded:
For example, let's take the following code in C (happens with any language with both line and block comment):

i = 0 /* 0 */;
j = 1 /* 1 */;
k = 2 /* 2 */;

If the three lines are selected and the command toggle line comment is called (ctrl+/ by default) then the block comment around 1 is removed. If only two lines are selected then the two line are correctly commented with a // at the beginning of the line.

Looking at the code in comment.py this seems to comes from the way the remove block_block_comment works: it try to extract the scope from the middle of the selection and if the middle is a block comment then it gets toggled ...

I am not sure exactly how to fix this issue properly (apparently it was done this way instead of looking directly at start and beginning of the region to avoid some issue with HTML comment ...), but at least when the toggle comment is called with block to false it should never affect the block comment, so a beginning of a fix is provided here:

@@ -203,7 +203,7 @@
                 # region spans languages, nothing we can do
                 continue
 
-            if self.remove_block_comment(self.view, edit, comment_data, region):
+            if block and self.remove_block_comment(self.view, edit, comment_data, region):
                 continue
 
             if self.is_entirely_line_commented(self.view, comment_data, region):

The problem still appears when toggle comment is called with block true, but since block comment cannot be embedded one in another, this is less of a concern.

@MattDMo
Copy link
Contributor

MattDMo commented Jan 9, 2017

This issue is not relevant to this repo. As stated in the README:

Missing Packages
This repository only contains syntax-definition-focused packages. Notably, packages such as Default and Theme - Default are not included.

I would suggest reposting this in SublimeTextIssues/Core, which deals with general bug reports. Make sure to search first to see if it has already been reported.

deathaxe pushed a commit to deathaxe/sublime-packages that referenced this issue Aug 25, 2019
This PR proposes to close some already fixed issues, which were not (correctly) referenced in the fixing pull requests.

Closes sublimehq#442
Closes sublimehq#685
Closes sublimehq#691 (invalid)
Closes sublimehq#795
Closes sublimehq#807
Closes sublimehq#903
Closes sublimehq#1141
Closes sublimehq#1172
Closes sublimehq#1245
Closes sublimehq#1257
Closes sublimehq#1286
Closes sublimehq#1320
Closes sublimehq#1357
Closes sublimehq#1382 (wontfix)
Closes sublimehq#1403
Closes sublimehq#1451
Closes sublimehq#1453 (maybe)
Closes sublimehq#1472
Closes sublimehq#1495
Closes sublimehq#1540
Closes sublimehq#1542
Closes sublimehq#1565
Closes sublimehq#1576
Closes sublimehq#1625
Closes sublimehq#1880
Closes sublimehq#1898
Closes sublimehq#1940 (invalid)
@wbond
Copy link
Member

wbond commented Oct 24, 2019

This appears to not really be a syntax issue, but rather a command issue that is part of the C++ codebase or the Default packages (which is not open source here). A report at https://github.com/SublimeTextIssues/Core would be appropriate, although there may already be one there.

@wbond wbond closed this as completed Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants