Skip to content

Commit 7ba49dd

Browse files
authored
Merge pull request #425 from lambdalisue/popup-nobuflisted
Fix invalid behavior when popup window is shown on Neovim
2 parents eee2649 + a808fc3 commit 7ba49dd

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

autoload/fern/internal/drawer/auto_restore_focus.vim

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ endfunction
1313

1414
function! 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
3131
endfunction
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+
3348
augroup fern_internal_drawer_auto_restore_focus
3449
autocmd!
3550
autocmd WinEnter * nested call s:auto_restore_focus()

autoload/vital/_fern/App/Action.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ function! s:list(...) abort
108108
let conceal = a:0 ? a:1 : v:true
109109
let l:Sort = { a, b -> s:_compare(a[1], b[1]) }
110110
let rs = split(execute('nmap'), '\n')
111+
call filter(rs, {_, v -> match(v, '^n') != -1})
111112
call map(rs, { _, v -> v[3:] })
112113
call map(rs, { _, v -> matchlist(v, '^\([^ ]\+\)\s*\*\?@\?\(.*\)$')[1:2] })
113114

autoload/vital/_fern/App/WindowLocator.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ let s:conditions = [
1616
\ { wi -> !getbufvar(wi.bufnr, '&previewwindow', 0) },
1717
\]
1818

19+
" Add condition to make sure that the window is not floating
20+
if exists('*nvim_win_get_config')
21+
call add(s:conditions, { wi -> nvim_win_get_config(wi.winid).relative ==# '' })
22+
endif
23+
1924
function! s:score(winnr) abort
2025
let winid = win_getid(a:winnr)
2126
let wininfo = getwininfo(winid)

autoload/vital/fern.vital

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
fern
2-
5591eeba1bdae8e615c6460be211ea6e88d95c05
2+
1f5becb7cfdb83ebe3af9228038d7714cf088726
33

44
App.Spinner
55
Async.CancellationTokenSource

0 commit comments

Comments
 (0)