Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop auto_match_enabled to insert a matching bracket when it is already there #142

Open
evandrocoan opened this issue Sep 20, 2019 · 0 comments

Comments

@evandrocoan
Copy link
Owner

evandrocoan commented Sep 20, 2019

  1. Stop auto_match_enabled to insert a matching bracket when it is already there sublimehq/sublime_text#2982 (comment)

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).

evandrocoan added a commit to evandrocoan/SublimePackageDefault that referenced this issue Sep 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant