Skip to content

Commit 64bb161

Browse files
committed
Fix not updating 'b:AutoCenter_MaxChangeNr' when a change in Insert mode
or Replace mode is done.
1 parent ad5a8e0 commit 64bb161

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

autoload/AutoCenter.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function! AutoCenter#On() "{{{
2020
" text changes. So we don't center text in these cases.
2121
autocmd TextChanged,TextChangedI *
2222
\ if !s:isUndoRedo() | call s:center() | endif
23-
autocmd BufEnter * call s:upMaxChangeNr()
23+
autocmd BufEnter,InsertLeave * call s:upMaxChangeNr()
2424
augroup END
2525
call s:upMaxChangeNr()
2626
call s:saveMapping() " Save mappings for later restoring.
@@ -56,7 +56,7 @@ function! s:center() "{{{
5656
call cursor('.', l:curpos + indent('.'))
5757
" An ongoing change in Insert mode or Replace mode is not taken as a new
5858
" change if updating the 'b:AutoCenter_MaxChangeNr' during this time. To avoid
59-
" this, wait until it is done.
59+
" this, wait until it is done, i.e., the autocmd event 'InsertLeave' occurs.
6060
if mode() !~ '^[iR]'
6161
call s:upMaxChangeNr()
6262
endif

0 commit comments

Comments
 (0)