Alexey-T / CudaText

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

Shouldn't prevent inserting closing pair after caret leaves the block #5659

Closed pintassilgo closed 1 month ago

pintassilgo commented 1 month ago
if (/\s/.test(str) {
  return;
}

Let's say I have this bad JS code. It's missing a ) in first line. If I place caret after str and press ), it should print this char, so that line ends with )) { so that code is good. VSCode works as expected. But Cuda just moves caret to the right, keeping just one ).

Suggested way to handle this:

So, for instance, if I type in a new line if (, Cuda will insert the closing pair ) next to the cursor, then I type the condition expression, then press ), Cuda doesn't insert it because it was already there: correct. But once user moves caret out of the block, for instance if they place it in other line, then moves it back, Cuda shouldn't prevent the typing of ).

I guess that's exactly how VSCode behaves.

Alexey-T commented 1 month ago

2 arguments against this

  1. Sublime does it like Cud.
  2. adding this needs some memory for previous input. so it's more hard to code. also: work of the bracket typing will be different depending on memory state: when memory 'allows' to insert, when not. and when 'allows', I can reopen file, move caret up/down, and then Cud 'disallows' to insert bracket? bad!