Skip to content

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

@evandrocoan

Description

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions