microsoft / vscode

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

Deleting pairs of character closures too aggressively #118270

Closed mwpowellhtx closed 3 years ago

mwpowellhtx commented 3 years ago

Steps to Reproduce:

Deleting within pairs of character closures too aggressive... i.e. something like this:

["...", [0]]
//         ^

Position cursor before the last closing bracket and backspace, the [0] only. The trailing ] gets included in that operation in error. Should not be.

Does this issue occur when all extensions are disabled?: Yes/No

alexdima commented 3 years ago

@mwpowellhtx What programming language are you using? Are those brackets present in the file when the file is opened or were they automatically-inserted when typing [ ?

mwpowellhtx commented 3 years ago

@alexdima SQF. Concerning the second question, I'm not positive, but I don't think it matters either way.

alexdima commented 3 years ago

For overtyping ], we keep track if the ] was automatically inserted when typing [. Pressing backspace does not look at that, and perhaps it should, similar to overtyping.

alexdima commented 3 years ago

There is now a new editor option, editor.autoClosingDelete which is auto by default, which means it will delete closing characters only if those characters were automatically inserted by the editor recently. The other options are always which was the current behavior until now, and never which means to never delete closing characters. This is now consistent with editor.atuoClosingOvertype.

mwpowellhtx commented 3 years ago

@alexdima And by "now" some idea as to which version? Thanks, and good to know, thank you.

alexdima commented 3 years ago

next insiders / stable 1.55.x

mwpowellhtx commented 3 years ago

Perfect, thank you, sir(s).

alexdima commented 3 years ago

To verify:

mwpowellhtx commented 3 years ago

Thanks. 90% positive that any pair will work, AFAIK, I just chose square brackets, in this instance, []. i.e. (), {}, "", '', etc.

isidorn commented 3 years ago

This works great -> verified. However I found one case of auto unexpected auto closing behavior. It is already happening in stable however, filled this issue https://github.com/microsoft/vscode/issues/119612

bogdan-d commented 3 years ago

There is now a new editor option, editor.autoClosingDelete which is auto by default, which means it will delete closing characters only if those characters were automatically inserted by the editor recently. The other options are always which was the current behavior until now, and never which means to never delete closing characters. This is now consistent with editor.atuoClosingOvertype.

I need to point out that this change, which I consider a 'breaking' change, is not mentioned anywhere in the latest release notes: https://code.visualstudio.com/updates/v1_55. I got here by searching for 'autoClosingDelete' in the issues page, a config option which I stumbled upon by chance in the settings page while trying to figure out what was wrong with the editor.

alexdima commented 3 years ago

@mister-glass Very sorry about this. I forgot to mention this in the release notes. I will make a PR to add a section about this.

EDIT: Done via https://github.com/microsoft/vscode-docs/pull/4466