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 374 forks source link

Check that a key is present before attempting to remove it #333

Closed ithinuel closed 3 years ago

ithinuel commented 3 years ago

When opening several files of the same filetype and AutoPairsDefine is used with au FileType … let b:AutoPairs = …, AutoPairsDefine is called several times but reuses the same dictionary set in the first call to AutoPairsDefine.

Let's assume we use

au FileType verilog let b:AutoPairs = AutoPairsDefine({}, ['`'])

On the first buffer it removes the pair

"`": "`"

but the key no longer exists in g:autopairs_defaultpairs when the other buffers are loaded resulting in ugly error messages.

This PR fixes that issue.

LunarWatcher commented 3 years ago

Dupe of #298 which I've merged into my fork. See also #309

ithinuel commented 3 years ago

Thanks for the heads up, Migration completed :)