jiangmiao / auto-pairs

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

Square bracket does not close when other closing brace is present #369

Open ei14 opened 10 months ago

ei14 commented 10 months ago

Unexpected behavior occurs in the following example.

Open a file containing these 3 characters: ([). Enter insert mode so that your cursor follows after the opening square bracket. Type ].

Expected: Since the closing parenthesis ) does not form a pair with the opening square bracket [, typing a closing square bracket ] should cause a closing square bracket to appear.

Actual: The closing parenthesis is treated as forming a pair with the opening square bracket. The cursor moves past the closing parenthesis ) and no square bracket is added.

This specifically occurs with square brackets. The issue is not present with other characters, as can be shown with the following example. Open a file containing [(]. Enter insert mode after the opening parenthesis. Type a closing parenthesis. As expected, the closing parenthesis appears, resulting in [()].

I believe this is unexpected behavior because it does not appear to be documented anywhere. I scanned every occurrence in the doc file of the character ], to no avail. If I am still missing something, please let me know.

If it is an intended feature, I believe it should be documented more explicitly, and there should be an option to disable this behavior.

LunarWatcher commented 10 months ago

What's the output of :echo b:AutoPairs and :echo b:AutoPairsList? Is it limited to a specific filetype?

ei14 commented 9 months ago

Found the issue. There's an undocumented variable called g:AutoPairsWildClosedPair. This should be added to the documentation.