In VSCode language extension while comment toggling, comment indicator goes to 1 column left side from cursor pointer #2363
-
|
I am creating a language extension, we don't use 1st column in this language purposely. So My language code start from 2nd column only. Now when I comment using "CTRL+/" (comment toggling) language code statement, Comment indicator (!) goes to first column (which is invalid in my language), my code shift by 1 column to right side. I have to explicitly move comment indicator to 2nd column. then only comments are recognised by Textmate grammar. Please checkout the below image. Is there a way to configure such thing in vscode language extension. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
|
Hi @jitendra19 , I would suggest you to add that extra column directly in Something like this {
"comments": {
"lineComment": " !",
"blockComment": [ "{", "}" ]
},
...
}And while using the But, a quick test on one of my language extensions, removing the line comment didn't work, and instead, another comment was added. And if the code is indented, sometimes the comment was added in the second column after the indent. So, I'm not it is a starting point for you, but if you don't find another alternative, maybe worth a try. Hope this helps |
Beta Was this translation helpful? Give feedback.
-
|
@alefragnani Hey , I tried the above solution and the toggle stopped working. Any suggestions how to fix this further? |
Beta Was this translation helpful? Give feedback.
-
|
there is a issue and PR for this |
Beta Was this translation helpful? Give feedback.

Unfortunately not. As I commented, once I used a whitespace as the first character, the
Toggle Line Commentstopped toggling. I tried updating the.tmLanguagefile contained on my language extension, but didn't make any difference.I'm not familiar with this area of VS Code source, but it seems the internals of the
Toggle Line Commentcommand does ignore leading whitespace while deciding if it should remove comments or not (function_analyzeLinesinLineCommentCommandclass). If that's the case, I suppose you should ask for a feature request, so the VS Code team could evaluate if/how this could be achieved.Hope this helps