Alexey-T / CudaText

Cross-platform text editor, written in Free Pascal
Mozilla Public License 2.0
2.51k stars 173 forks source link

Folding comments is not working #4924

Closed pintassilgo closed 1 year ago

pintassilgo commented 1 year ago

For example, this JavaScript content:

/* ...
...
...
*/

Should display a folding button to fold the entire comment block. At least for me it's not working.

Also, if I understood correctly, the option auto_fold_comments = 1 should enable the folding button for consecutive comment lines like

// the dev writing this comment
// likes to use this pattern for comments
// instead of using comment blocks with marks /* a \n b \n c \n */
// It would be good if Cuda can fold these consecutive comments lines as if they were a block

But it doesn't work for me either.

Alexey-T commented 1 year ago

Confirmed, it is not working; will see it, thanks.

Alexey-T commented 1 year ago

linux beta to test: cudatext.zip

pintassilgo commented 1 year ago

For me, nothing has changed with this build, both examples from initial comment are still without folding button.

Alexey-T commented 1 year ago

Did you set "auto_fold_comments" to value>1 ?

pintassilgo commented 1 year ago

Right, thanks. It was 1, changed to 2 and now it almost works.

For comment block /* */ it's fine. But I think such block should be treated just like any code block like if () { } i.e. it should be foldable by default, not needing to change the option. I guess this is how any code editor works.

I think of auto_fold_comments as being for consecutive non-block comments, in case of JS are lines starting with //. It's working, but the last consecutive comment line is missing from the folding.

image

Edit: I restarted Cuda and now the last consecutive comment line is correctly foldable. Weird, but the fact is now is working, so I guess I can close this. Thanks!

Just reinforcing my opinion that comment blocks like /* */ should be foldable by default just like any code block without needing to tweak options.

pintassilgo commented 1 year ago

Right, thanks. It was 1, changed to 2 and now it almost works.

For comment block /* */ it's fine. But I think such block should be treated just like any code block like if () { } i.e. it should be foldable by default, not needing to change the option. I guess this is how any code editor works.

I think of auto_fold_comments as being for consecutive non-block comments, in case of JS are lines starting with //. It's working, but the last consecutive comment line is missing from the folding.

image

Alexey-T commented 1 year ago

lines starting with //. It's working, but the last consecutive comment line is missing from the folding.

It's minor bug , i could not solve it- add any ID after comment and it will be ok.

Alexey-T commented 1 year ago

that comment blocks like / / should be foldable by default just like any code block without needing to tweak options.

Not agree

pintassilgo commented 1 year ago

It's minor bug , i could not solve it- add any ID after comment and it will be ok.

Now I see, you're right. This bug only happens when consecutive comments are the last non empty lines of the file (line with just tab/space indentation still counts as empty).

pintassilgo commented 1 year ago

I can understand the reasoning of not treating comment blocks as foldable by default because the user may be interested in fold the code but not comments, similar to header files, they're not interested in implementation but want to read the descriptions.

This reminds me of a new feature suggestion: command to fold all comment blocks/consecutive lines of the file at once, without touching any code blocks. Current folding commands don't differentiate between comment and code, like "fold level 1" will fold both code and comments (when auto_fold_comments > 1).

Alexey-T commented 1 year ago

This wish should be the request for small plugin cmd, e.g. for CudaExt ...

pintassilgo commented 1 year ago

This wish should be the request for small plugin cmd, e.g. for CudaExt ...

Should I create this request somewhere?

Alexey-T commented 1 year ago

Yes, in Cud main repo 'issues'