Skip to content

Commit

Permalink
Merge pull request #436 from lambdalisue/fix-435
Browse files Browse the repository at this point in the history
Fix 'E242' when smart-quit feature on Neovim 0.7.1
  • Loading branch information
lambdalisue authored Jul 23, 2022
2 parents e90cdeb + 54f15a1 commit 4a319ff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 4 additions & 3 deletions autoload/fern/internal/drawer/smart_quit.vim
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ function! s:smart_quit() abort
elseif keep
" Add a new window to avoid being a last window
let winid = win_getid()
if has('nvim')
call s:complement(winid, width)
else
if has('patch-8.1.1756') || has('nvim-0.7.1')
" Use timer to avoid E242 in Vim
" https://github.com/lambdalisue/fern.vim/issues/435
call timer_start(0, { -> s:complement(winid, width) })
else
call s:complement(winid, width)
endif
else
" This window is a last window of a current tabpage
Expand Down
10 changes: 8 additions & 2 deletions test/behavior/drawer-smart-quit.vimspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
if has('win32')
command! Relax sleep 100m
else
command! Relax sleep 1m
endif

Describe drawer-smart-quit
After all
%bwipeout!
Expand All @@ -14,7 +20,7 @@ Describe drawer-smart-quit
Fern . -drawer -keep -stay
Assert Equals(winnr('$'), 2)
quit
sleep 1m
Relax
Assert Equals(winnr('$'), 2)
End

Expand All @@ -23,7 +29,7 @@ Describe drawer-smart-quit
Fern . -drawer -keep -stay
Assert Equals(winnr('$'), 2)
quit
sleep 1m
Relax
Assert Equals(winnr('$'), 1)
End
End
Expand Down

0 comments on commit 4a319ff

Please sign in to comment.