handle logic to auto close and delete brackets
Handle Auto Close Parentheses, Braces, Brackets
To solved https://github.com/microsoft/edit/issues/488 I add logic to handle:
Auto close: If you type '(' or '[' or '{' with have auto close that and cursor will go between these.Auto delete: For example: You have (|) ( this is parentheses with cursor between, if you delete - typeBACKboth open and close will be delele)
@microsoft-github-policy-service agree
Could this feature be made optional?
For me this is one of the most annoying features in other editors, frequently causing me to write things like [2]] or if (some_thing) { do_something(); } )}). And with the auto-delete it makes it even harder to prevent because when I then delete the closing bracket it also deletes the opening one. Another example is retro-actively adding a () around an existing condition.
Some more general remarks:
- It leaks syntax of the language written into the editor itself.
- There are cases were you just want a single opening bracket, for example in multi line comments or strings.
@Consolatis You can try my ver first. Because delete only auto delete if between that is empty. For example:
- [|] -> if your cursor is between and you type
BACKbutton -> will auto delete both open and close - [some thing]| -> if your cursor is right close and you type
BACKbutton -> you just delete close one.
My auto just delete with not thing between open and close. Can you check that first. If still annoy for you I will add some change to make that to optional or remove that feature.
I'm not entirely sure about merging this logic just yet without having a settings model allowing users to turn this behavior off. I'll continue to let this PR sit for a while longer but try to keep it in the back of my mind.
@lhecker If needed, I’ll update with the settings ( from project) later. I see that my PR is currently out of date with the main branch.