Add spacing at beginning/end of a comment
Right now in CudaText when placing a comment line/block, there's no spacing between comment marker and comment content, unlike what most other editors would do (VSCode, Sublime, etc.)
TypeScript example:
Before commenting
This is a comment <---
private initForm() {
this.themeConfigForm = this.fb.group({
primary: [null],
primaryShade: [null],
secondary: [null]
});
}
Current result:
//This is a comment
private initForm() {
this.themeConfigForm = this.fb.group({
primary: [null],
primaryShade: [null],
secondary: [null]
});
}
Expected result:
// This is a comment <-- notice there should be a space between double slashes and first character of the comment
private initForm() {
this.themeConfigForm = this.fb.group({
primary: [null],
primaryShade: [null],
secondary: [null]
});
}
HTML example:
Before commenting:
This is a comment
Current result:
<!--This is a comment-->
Expected result:
<!-- This is a comment --> (There should be a space on both ends of the comment content)
Don't know if this design is intentional, but would love to have at least a flag to control this so that the comment style is consistent with other text editors.
I just found that Sublime works so. Ok, todo. Sublime: block comment in C lexer dont add spaces. But it adds spaces for Html. So i Will also add spaces when lexer name has 'HTML' string. Todo.
works fine on my powershell
so, maybe just lexer properties…
PowerShell lexer file has
LineComment = '# '
so includes space after '#'. this is not normal for other lexers. I will fix the powershell lexer and remove space.
1st part of work. adding (forcing) space after line-comment-chars.
seems, done.
pls test it, download file py/cuda_comments/cd_comments.py from this repo and update it.
2nd part, about block comments, will be later, if 1st part ok.
About block comments. In Sublime, block comment in C++ dont surround text with spaces, but in HTML it does. Why?
Maybe @pintassilgo knows?
There's no formal requirement to use spaces. Source. But I agree it's a good practice, without spaces it's ugly. If you search for <!-- in the link to look at other examples, you'll see they use spaces.
part 2 is done too. stream-comment command. updated in git too. spaces are added in stream comments in all lexers (C, C++, HTML...)