1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-03-24 18:52:22 +08:00

Fix: smart quit should skip floating windows and popup (#3640)

@bug vim winnr('$') do not include popup
 ref: https://github.com/vim/vim/issues/6474
This commit is contained in:
Wang Shidong 2020-07-18 10:43:52 +08:00 committed by GitHub
parent c937c0e2fd
commit 823d288b35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 10 deletions

View File

@ -59,6 +59,30 @@ else
endfunction
endif
if has('nvim')
function! s:self.is_float(winnr) abort
let id = win_getid(a:winnr)
if id > 0
return has_key(nvim_win_get_config(id), 'col')
else
return 0
endif
endfunction
else
function! s:self.is_float(winnr) abort
let id = win_getid(a:winnr)
if id > 0
try
return has_key(popup_getoptions(id), 'col')
catch /^Vim\%((\a\+)\)\=:E993/
return 0
endtry
else
return 0
endif
endfunction
endif
function! SpaceVim#api#vim#window#get() abort
return deepcopy(s:self)

View File

@ -9,6 +9,7 @@
scriptencoding utf-8
let s:BUFFER = SpaceVim#api#import('vim#buffer')
let s:WIN = SpaceVim#api#import('vim#window')
let g:unite_source_menu_menus =
@ -289,6 +290,8 @@ endfunction
fu! SpaceVim#mapping#SmartClose() abort
let ignorewin = get(g:,'spacevim_smartcloseignorewin',[])
let ignoreft = get(g:, 'spacevim_smartcloseignoreft',[])
" @bug vim winnr('$') do not include popup
" ref: https://github.com/vim/vim/issues/6474
let win_count = winnr('$')
let num = win_count
for i in range(1,win_count)
@ -298,6 +301,8 @@ fu! SpaceVim#mapping#SmartClose() abort
let num = num - 1
elseif getwinvar(i, '&previewwindow') == 1 && winnr() !=# i
let num = num - 1
elseif s:WIN.is_float(i)
let num = num - 1
endif
endfor
if num == 1