You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incorrect comment highlighting with recent update #1573
I use the following method to quickly and easily comment out code blocks:
/*/code();// */
Adding a single * on the first line uncomments the code block, so you can toggle the code block with a single character:
/**/code();
// */
You can also toggle between 2 different code blocks with a single character, if you add * to the first line here:
/*/code("A");/*/code("B");
// */
The same works in all languages that use /* */ for multiline comments (the C "family", JavaScript, JSON with comments, and a similar thing even works in Lua). Dart is a bit weird in that it requires the space in // */ or the code will fail to compile, but that's a "bug" in Dart, not in this package.
However, a recent change in this package (maybe related to #1498) breaks syntax highlighting.
The last line (// */) seems to be treated as a one line comment, and the end of the multiline comment is ignored, so the rest of the file is highlighted as a comment:
If there's a later */ (not part of another comment), the comment highlighting stops there, but it's (correctly) marked as a syntax error:
The same bug also occurs with a simple /* // */ (the rest of the file is highlighted as a comment):
This is a relatively recent change, I remember the highlighting working correctly about a week ago (but of course, that may depend on when I updated this package).
Yikes! Thanks for the report. This is very likely related to the issue you linked or #1554 (which shipped on Friday). I'll do some digging.
FWIW, VS Code has shortcuts for quickly commenting out blocks of code that might be easier than this (though it doesn't change that this needs fixing).
FWIW, VS Code has shortcuts for quickly commenting out blocks of code that might be easier than this (though it doesn't change that this needs fixing).
I know, but this is "universal" (works in any editor, lots of different languages, etc.), and also nice because it allows you to "toggle" between 2 different code blocks. :)
And I also consider this to be easier/faster, since it's just one character to comment/uncomment the block, instead of highlighting the code block and pressing a keyboard shortcut. At least it's easier once you have the "scaffolding comments" around the code block, before that, maybe not.
But like you said, this should be fixed regardless, since even a simple /* // */ also breaks highlighting.
Yeah, that makes sense if it's always the same block (though the selection can handle many).
Here's the impact of the change I just made. I've saved this file in the repo now to make it easier to evaluate these in future (it's a bit of a game of whack-a-mole - I haven't found an official syntax for the language that is maintained with language changes).
If there's anything other combinations of things you think worth adding, do let me know or (feel free to edit the file in a PR).
@devoncarew FYI - one of my previous changes to support nested comments resulted in allowing line comments inside block comments, which resulted in the end-of-block-comment marker being ignored if it was on the same line.
Activity
kankaristo commentedon Apr 2, 2019
Temporary fix is to install this package, which provides Dart syntax highlighting only (works together with this package, but doesn't have the same bug):
https://marketplace.visualstudio.com/items?itemName=oscarcs.dart-syntax-highlighting-only
DanTup commentedon Apr 2, 2019
Yikes! Thanks for the report. This is very likely related to the issue you linked or #1554 (which shipped on Friday). I'll do some digging.
FWIW, VS Code has shortcuts for quickly commenting out blocks of code that might be easier than this (though it doesn't change that this needs fixing).
kankaristo commentedon Apr 2, 2019
I know, but this is "universal" (works in any editor, lots of different languages, etc.), and also nice because it allows you to "toggle" between 2 different code blocks. :)
And I also consider this to be easier/faster, since it's just one character to comment/uncomment the block, instead of highlighting the code block and pressing a keyboard shortcut. At least it's easier once you have the "scaffolding comments" around the code block, before that, maybe not.
But like you said, this should be fixed regardless, since even a simple
/* // */also breaks highlighting.Tweak block comments to not treat things inside as line comments
DanTup commentedon Apr 2, 2019
Yeah, that makes sense if it's always the same block (though the selection can handle many).
Here's the impact of the change I just made. I've saved this file in the repo now to make it easier to evaluate these in future (it's a bit of a game of whack-a-mole - I haven't found an official syntax for the language that is maintained with language changes).
If there's anything other combinations of things you think worth adding, do let me know or (feel free to edit the file in a PR).
@devoncarew FYI - one of my previous changes to support nested comments resulted in allowing line comments inside block comments, which resulted in the end-of-block-comment marker being ignored if it was on the same line.
Tweak block comments to not treat things inside as line comments
devoncarew commentedon Apr 4, 2019
Thanks! I opened dart-atom/dart#1189.