From 86e4f10b26be46b2160b344b48ab2776b54c0272 Mon Sep 17 00:00:00 2001 From: Thomas Buckley-Houston Date: Mon, 12 Jun 2017 14:08:27 +0700 Subject: Millisecond delay before checking &buftype Fixes bug where some buffers, well actually a lot of buffers, don't immediately set their &buftype/&modifiable/&readonly state. Hopefully now any buffer like NERD_Tree, Fugitive's GBlame, Vim-Plug's update buffer, quicklist, location, etc, etc. This has been a looooong standing bug. It makes me very hapy to fix this. I've set the delay to 1 millisecond, so be prepared that more is needed. --- autoload/novim_mode.vim | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'autoload') diff --git a/autoload/novim_mode.vim b/autoload/novim_mode.vim index 0abe936..a8de55a 100644 --- a/autoload/novim_mode.vim +++ b/autoload/novim_mode.vim @@ -4,8 +4,6 @@ function! s:IsEditableBuffer() if &buftype ==# 'nofile' \|| !&modifiable \|| &readonly - \|| bufname('%') =~# 'NERD_tree_' - \|| bufname('%') =~# 'fugitiveblame' return 0 else return 1 @@ -46,7 +44,10 @@ function! s:InsertAndSelectionBehaviour() " Intelligently set/unset insertmode augroup start_insertmode autocmd! - autocmd BufEnter * call s:InsertMode() + " The timer here delays the call to check whether the current buffer + " is an editable one. Without the delay, the check is often too early + " to correctly get the value of `&buftype`, etc. + autocmd BufEnter * call timer_start(1, {->execute('call s:InsertMode()')}) augroup END " Mostly changes the way selection works. -- cgit v1.2.3-70-g09d2