CudaText icon indicating copy to clipboard operation
CudaText copied to clipboard

Add spacing at beginning/end of a comment

Open LouieTian0209 opened this issue 1 year ago • 7 comments

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.

LouieTian0209 avatar Aug 21 '24 02:08 LouieTian0209

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.

Alexey-T avatar Aug 21 '24 07:08 Alexey-T

works fine on my powershell

image

so, maybe just lexer properties…

MiroslavMatas avatar Aug 21 '24 11:08 MiroslavMatas

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.

Alexey-T avatar Aug 21 '24 12:08 Alexey-T

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.

Alexey-T avatar Aug 22 '24 13:08 Alexey-T

About block comments. In Sublime, block comment in C++ dont surround text with spaces, but in HTML it does. Why?

Maybe @pintassilgo knows?

Alexey-T avatar Aug 22 '24 14:08 Alexey-T

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.

pintassilgo avatar Aug 22 '24 14:08 pintassilgo

part 2 is done too. stream-comment command. updated in git too. spaces are added in stream comments in all lexers (C, C++, HTML...)

Alexey-T avatar Aug 23 '24 04:08 Alexey-T