-
-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Well, I just exposed a simple problem but did not discoursed about how to actually fix and how it would affect other situations. A simple fix I did on my installation for now was this:
{ "key": "following_text", "operator": "not_regex_match", "operand": ".*\\].*", "match_all": true },With this, I dumbly cut the insertion of the matching bracket, if any closing bracket was found. Indeed, this is not ideal. A more elegant solution would be to detect whether there are unbalanced brackets (this should be context aware, for example, if I inside a comment, and I am typing, this should isolate itself into that comment. But if I am on a code block, it should ignore comments and count all non-commented brackets and decide whether a matching bracket is missing/required. Then, fill it/fulfill it or do nothing.
Now I discoursed a little about its implementation, I think a plugin could do that "smart" behavior by overriding the default brackets keys
[,(, etc. Or either this could be something a Language Server (LSP) could do/provide).