diff options
author | Thomas Buckley-Houston | 2017-06-12 07:08:27 +0000 |
---|---|---|
committer | Thomas Buckley-Houston | 2017-06-12 07:08:27 +0000 |
commit | 86e4f10b26be46b2160b344b48ab2776b54c0272 (patch) | |
tree | 95b98102c28660082828e9bfd1de274d8105abf5 /autoload | |
parent | 2de00abbbb6730bc4af4f1f134dc557cd991d299 (diff) |
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.
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/novim_mode.vim | 7 |
1 files changed, 4 insertions, 3 deletions
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. |