microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.65k stars 28.68k forks source link

the default value of `editor.autoClosingDelete` should be "always" #129980

Open ZYinMD opened 3 years ago

ZYinMD commented 3 years ago

The new setting editor.autoClosingDelete has been introduced for several months now. It can be set to auto, always or never.

For years, the default behavior was always, but since this feature was added, the default for new users became auto. After months of testing, I've come to the conclusion that always is a better candidate for default, because auto is not smart enough, for several reasons:

  1. When a pair is created by auto-insert, then I move the cursor away, then come back and delete, the program no longer remember it was auto-inserted, so auto-delete won't happen.
  2. After auto-insert, if I keep the cursor in place, but switch to a different tab and switch back, the program no longer remember it was auto-inserted, so auto-delete won't happen.
  3. Not to mention the case when I close a file and revisit it later.
  4. When you highlight a piece of text foo, then press a key to "auto surround" it, making it "foo" or (foo) or [foo], the pair is not considered auto inserted, and auto delete won't happen even if you delete immediately.
  5. When you see a string like "bar", and you double click it to highlight, then try to backspace×2 to delete it, it won't work.
  6. In snippets, say you have a snippet called "arrow", which is somethin like (|) => {|}, the pairs are not considered auto inserted, so when you tab through them and delete, auto delete won't happen.
  7. Generally, whenever you have a cursor in between brackets like {|} then press backspace, human brains expect a consistent outcome every time. Since human brains don't remember whether the pair of brackets was auto-inserted, the current behavior always feel inconsistent and not intuitive.

1-6 happens a lot, especially 1 and 2 happens so often, that in 90% cases auto delete won't happen, so the new default settings is mostly equal to "never", which is wasting a nice feature for new users. In the rest 10% cases when auto delete does happen, it's even worse, due to the inconsistency in 7.

hediet commented 2 years ago

There's also a bug where pairs inserted by snippets behave inconsistently, if you're interested I can create an issue to reproduce it.

Please create a separate issue for that.

As for the main issue, I think this is not a bug but rather a discussion of what value should be default. I think we should wait for more feedback on this.

ZYinMD commented 2 years ago

Hi @hediet thanks for replying after 2.5 months. I believe the said bug regarding snippets has disappeared during this time, but there are still other problems about this feature. I just re-wrote both the title and body of this issue to better describe it, you could take a look.

In general, I think the devs have worked hard on this feature, then excitedly shipped it, but things are not as simple as it seems.

hediet commented 2 years ago

I think the idea of autoClosingDelete is to make the autoClose feature less annoying (backspacing an opening bracket should not leave a (auto closed) closing bracket behind), not necessarily to enable the feature of balanced bracket pair deletion.

ZYinMD commented 2 years ago

backspacing an opening bracket leaves a closing bracket behind

The current behavior of default setting for new users autoClosingDelte: auto does exactly that, in all of the cases I mentioned. If you think that's annoying, you should set it to always, which I think should be the default for new users, which is the whole point of this issue.

balanced bracket pair deletion

I was never referring to this features, I actually never knew it was a thing, before you showed me.