Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Do NOT count popup windows on auto duplication (#474) #475

Merged
merged 1 commit into from
May 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion autoload/fern/internal/viewer/auto_duplication.vim
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function! fern#internal#viewer#auto_duplication#init() abort
endfunction

function! s:duplicate() abort
if len(win_findbuf(bufnr('%'))) < 2
if s:count_non_popup_windows('%') < 2
return
endif
" Only one window is allowed to display one fern buffer.
Expand All @@ -21,3 +21,22 @@ function! s:duplicate() abort
let bufname = fern#fri#format(fri)
execute printf('silent! keepalt edit %s', fnameescape(bufname))
endfunction

function! s:count_non_popup_windows(expr) abort
let winids = win_findbuf(bufnr(a:expr))
return len(filter(winids, {_, v -> !s:is_popup_window(v)}))
endfunction

if exists('*win_gettype')
function! s:is_popup_window(winid) abort
return win_gettype(a:winid) ==# 'popup'
endfunction
elseif exists('*nvim_win_get_config')
function! s:is_popup_window(winid) abort
return nvim_win_get_config(a:winid).relative !=# ''
endfunction
else
function! s:is_popup_window(winid) abort
return getbufvar(winbufnr(a:winid), '&buftype') ==# 'popup'
endfunction
endif