Closed pintassilgo closed 1 month ago
Yes, I agree it must be improved.
Not that it matters, but this is a bug, not enhancement... Code folding is expected to collapse the clicked block, not to include a line that initiates another block. As it is with any other app supporting code folding.
Suggestion is the improvement. Logic of it is - if after block ending we have more lexer tokens on the same line, lets decrement ending's y coord.
I improved it. before it was fixed for JSON lexer only. via property in .cuda-lexmap file. now we don't need that property. it's auto detected. now it works for ALL lexers (not only {} based).
beta cudatext.zip
Thanks, fixed.
A couple of minor visual details:
{ ... }
, but in this case it looks weird because closing brackets is in the line below, while opening brackets is correctly hidden by the folding. Can you understand? The closing brackets in second line looks wrong because there's already a closing brackets in first line.So maybe you should think of a different default visual indicator for collapsed block. Just for reference:
if
with many conditionals. It's a good practice to list them in multiple lines, turning the group of conditions as an own foldable block. So, for instance:if (name === 'Alex' ||
name === 'AlexT' ||
name === 'Alex T') {
a = 1;
b = 2;
} else {
a = 0;
}
If you click to fold the first block (if
conditionals), then you can't fold the child block inside the if
. Also, in this case Cuda doesn't display the opening brackets following the if ()
, which is a bit strange.
Thanks.
I disagree, I like being able to fold them, for me it's better keeping current than doing this change you suggested. If doable, I suggest a little improvement of how Sublime handles this. When you fold the if ()
, the opening brackets is exposed at the first line:
In my opinion, this is the best visual. easy to understand, easy to see, beautiful... But it's not perfect because then you can't fold the { }
block. Actually you can, but only if you do it before you fold the ( )
block.
Sublime way is already an improvement to current Cuda, but to fix the issue of not being able to fold { }
when ( )
is fold, maybe user could be able to click the code folding column to fold it. By the way, this would be a good feature to have. Current, in order to fold a block with mouse you need to find and click the line that opens the block. It would be good if user can fold the block by clicking the folding column in any line (could be set by option). So, if user clicks inside the red circle in image below, it would fold the block.
will think about your last suggestion. now i see it is not good when 2+ ranges overlap and we click on overlapped line. also it don't work in Sublime. normal way to fold - is to click [+].
new beta. 1 and 2 fixed? i excluded the ')' and '}' char from fold-tooltip ( ... )
/ { ... }
.
cudatext.zip
Thanks, it's better now.
Regarding the click-on-fold-column-to-fold, I use that feature in Reddit and find it useful.
https://github.com/user-attachments/assets/d266f5aa-921f-4b4d-8d8e-bcf61e4e329d
Sometimes current code block is very long and you want to collapse it, you need to scroll till you find the line that opens the brackets. There's probably a hotkey to fold current block, but it would be good to have a good way to do it with the mouse too.
reddit ui is diffetent, each range has new column. we must not adapt to reddit.
seems i made all fixes. lets find more issues if any.
Collapse first line.
Expected (it works in any other editor):
Cuda (the
else
line is unexpectedly collapsed):