jiangmiao / auto-pairs

Vim plugin, insert or delete brackets, parens, quotes in pair
http://www.vim.org/scripts/script.php?script_id=3599
4.11k stars 373 forks source link

auto-pairs doesn't detect imbalanced pairs #270

Open MisterTicot opened 5 years ago

MisterTicot commented 5 years ago

In a situation like this:

if (x) {
  if (y) {
    |
}

Pressing } will jump to the last bracket rather than inserting one. I think it should detect that pair are imbalanced and insert a closing bracket instead.

nkakouros commented 4 years ago

Another example that I find myself quite often in is this:

echo "$|array[@]}"  # need to add `{`

or

echo |$[array[@]}"  # need to add `"`
mversic commented 4 years ago

yes, in it's current state this feature is unusable because I almost always want to add closing brace, because it's missing or otherwise I wouldn't be pressing it. I found that you can use let g:AutoPairsMultilineClose = 0 to disable this, but then you loose this feature entirely, even when it makes sense. It's a trade off. I find it better disabled

If AutoPairs plugin did some scope analysis it could support this feature in a sane way, otherwise it's just silly how it behaves. I haven't found other plugin that does this well.