diff --git a/plugin/auto-pairs.vim b/plugin/auto-pairs.vim index 2e848d7..62ab62b 100644 --- a/plugin/auto-pairs.vim +++ b/plugin/auto-pairs.vim @@ -114,20 +114,20 @@ let s:InsCntUndoResetCmd = "\=AutoPairsInsCntUndoReset()\" function! AutoPairsInsCntReset() if g:AutoPairsUseInsertedCount - let b:autopairs_ins_cnt__before_reset = b:autopairs_ins_cnt + let b:autopairs_ins_cnt__before_reset = AutoPairsInsCnt() let b:autopairs_ins_cnt = 0 endif endfunction function! AutoPairsInsCntInc(cnt) if g:AutoPairsUseInsertedCount - let b:autopairs_ins_cnt = b:autopairs_ins_cnt + a:cnt + let b:autopairs_ins_cnt = AutoPairsInsCnt() + a:cnt endif endfunction function! AutoPairsInsCntDec() if g:AutoPairsUseInsertedCount - let b:autopairs_ins_cnt = b:autopairs_ins_cnt - 1 + let b:autopairs_ins_cnt = max([AutoPairsInsCnt() - 1, 0]) endif endfunction @@ -135,12 +135,21 @@ function! AutoPairsInsCntAvail() let ret = 1 if g:AutoPairsUseInsertedCount - let ret = (b:autopairs_ins_cnt > 0) + let ret = (AutoPairsInsCnt() > 0) endif return ret endfunction +function! AutoPairsInsCnt() + let ret = 0 + + if exists('b:autopairs_ins_cnt') + ret = b:autopairs_ins_cnt + endif + + return ret +endfunction function! AutoPairsInsCntUndoReset() if g:AutoPairsUseInsertedCount