FYI I don’t think this is a bug (per se). I think the point of the keybinding is that when ST adds in your closing brackets for free it needs to allow for people who accidentally try to close them. Thus if you’re about to type a closing bracket, brace or quote and you’re next to one, it’ll overwrite/move the cursor forward rather than insert a new one. Consider the following use case:
Someone types
var a = '
ST2 shows (| denoting insertion point cursor):
var a = '|'
Developer then completes the string and types the ending quote (by mistake - ST2 already gave them one for free). Typed:
some string'
ST2 realises they ended the string it already tried to end for them, and skips over the quote (rather than doubling it up):
var a = 'a string'|
Rather than:
var a = 'a string'|'
So that’s a use case where it makes sense to skip over a bracket/brace/quote. But I understand in your situation this behaviour is unexpected and unwanted. Unfortunately there’s probably not a lot you can do about that. ST2 really tried to help by always automatically closing these things whenever it sees fit (presumably based on scope), but can’t always do so, thus leaving the developer having to add the ending bracket/brace/quote, and in those circumstances the behaviour I just described shouldn’t be used. But presumably it’s difficult for ST2 to know when and when not to use this heuristic, so it always does it, hoping that it doesn’t happen much.
So I can’t offer a fix, and nor am I defending the behaviour per se, just saying that I don’t think it’s a bug: it’s there to help you out in other situations and unfortunately gets in the way in this one. The bug in my eye is more that when you type your inside open bracket, the editor doesn’t automatically add a closing bracket for you. Having said that, I’ve noticed less of this happening lately (maybe some definitions were updated at some point).
The only time this is an issue for me now is when typing an opening bracket next to a word character, and then I understand completely that the editor can’t automatically close it for me. Consider the following example:
if (a == 5 && |b == 8) {
console.log('great');
}
If I go to add an opening bracket at the insertion point just to the left of the variable ‘b’ for a bit more specificity, then the editor doesn’t automatically close it for me (it’s unlikely I’ll want a closing one right next to the opening one, and the editor can’t read my mind as to where it should go (should it be ‘(b) == 8’ or ‘(b == 8)’?)). Then when I go to add the closing one to the right of the number ‘8’, it doesn’t appear to do anything because it thinks I’m inadvertently closing the bracket that (it assumes) it created automatically for me. This is the exact problem you’re having as described in your first post. It’d be interesting to see if you agree with me that the benefits of the system outweigh this one drawback.
If you really want a fix, I think there’s a setting to not dot he automatic completion of brackets and the like, which will presumably stop this closing-skip behaviour too, but then you lose the automatic closing which is so useful.