Skip to content

Commit

Permalink
Check that popup window exists before closing. #2
Browse files Browse the repository at this point in the history
  • Loading branch information
dstein64 committed Jan 5, 2024
1 parent fd468f1 commit 0557960
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions autoload/win.vim
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,24 @@ endfunction

function! s:ClosePopup(winid)
if s:popupwin
call popup_close(a:winid)
" The popup may no longer exist. #2
if !empty(popup_getpos(a:winid))
call popup_close(a:winid)
endif
elseif s:floatwin
" Keep track of available floatwin buffer numbers, so they can be reused.
" This prevents the buffer list numbers from getting high from usage of
" vim-win. This list is used by OpenPopup.
if !has_key(s:, 'floatwin_avail_bufnrs')
let s:floatwin_avail_bufnrs = []
" The floating window may no longer exist. #2
if nvim_win_is_valid(a:winid)
" Keep track of available floatwin buffer numbers, so they can be
" reused. This prevents the buffer list numbers from getting high from
" usage of vim-win. This list is used by OpenPopup.
if !has_key(s:, 'floatwin_avail_bufnrs')
let s:floatwin_avail_bufnrs = []
endif
call add(s:floatwin_avail_bufnrs, winbufnr(a:winid))
" The buffer is not deleted, which is intended since it's reused by
" OpenPopup.
call nvim_win_close(a:winid, 1)
endif
call add(s:floatwin_avail_bufnrs, winbufnr(a:winid))
" The buffer is not deleted, which is intended since it's reused by
" OpenPopup.
call nvim_win_close(a:winid, 1)
endif
endfunction

Expand Down

0 comments on commit 0557960

Please sign in to comment.