File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
autoload/fern/internal/viewer Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ function! fern#internal#viewer#auto_duplication#init() abort
1111endfunction
1212
1313function ! s: duplicate () abort
14- if len ( win_findbuf ( bufnr ( ' %' )) ) < 2
14+ if s: count_non_popup_windows ( ' %' ) < 2
1515 return
1616 endif
1717 " Only one window is allowed to display one fern buffer.
@@ -21,3 +21,22 @@ function! s:duplicate() abort
2121 let bufname = fern#fri#format (fri)
2222 execute printf (' silent! keepalt edit %s' , fnameescape (bufname ))
2323endfunction
24+
25+ function ! s: count_non_popup_windows (expr ) abort
26+ let winids = win_findbuf (bufnr (a: expr ))
27+ return len (filter (winids, {_, v - > ! s: is_popup_window (v )}))
28+ endfunction
29+
30+ if exists (' *win_gettype' )
31+ function ! s: is_popup_window (winid) abort
32+ return win_gettype (a: winid ) == # ' popup'
33+ endfunction
34+ elseif exists (' *nvim_win_get_config' )
35+ function ! s: is_popup_window (winid) abort
36+ return nvim_win_get_config (a: winid ).relative !=# ' '
37+ endfunction
38+ else
39+ function ! s: is_popup_window (winid) abort
40+ return getbufvar (winbufnr (a: winid ), ' &buftype' ) == # ' popup'
41+ endfunction
42+ endif
You can’t perform that action at this time.
0 commit comments