File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
autoload/fern/internal/drawer Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ endfunction
1313
1414function ! s: auto_restore_focus_pre () abort
1515 let s: info = {
16- \ ' nwin' : winnr ( ' $ ' ),
16+ \ ' nwin' : s: nwin ( ),
1717 \ ' tabpage' : tabpagenr (),
1818 \ ' prev' : win_getid (winnr (' #' )),
1919 \}
@@ -24,12 +24,27 @@ function! s:auto_restore_focus() abort
2424 if s: info is # v: null
2525 return
2626 endif
27- if s: info .tabpage is # tabpagenr () && s: info .nwin > winnr ( ' $ ' )
27+ if s: info .tabpage is # tabpagenr () && s: info .nwin > s: nwin ( )
2828 call win_gotoid (s: info .prev )
2929 endif
3030 let s: info = v: null
3131endfunction
3232
33+ if exists (' *nvim_win_get_config' )
34+ " NOTE:
35+ " Remove Neovim flating window from the total count
36+ function ! s: nwin () abort
37+ return len (filter (
38+ \ range (1 , winnr (' $' )),
39+ \ { _, v - > nvim_win_get_config (win_getid (v )).relative == # ' ' },
40+ \) )
41+ endfunction
42+ else
43+ function ! s: nwin () abort
44+ return winnr (' $' )
45+ endfunction
46+ endif
47+
3348augroup fern_internal_drawer_auto_restore_focus
3449 autocmd !
3550 autocmd WinEnter * nested call s: auto_restore_focus ()
You can’t perform that action at this time.
0 commit comments