mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-03 02:00:05 +08:00
fix(scrollbar): fix scrollbar on SPC number key binding
Problem:If win_count < number, SPC number will close scrollbar Solution: use vim#window.win_count api instead of winnr('$')
This commit is contained in:
parent
8937bc7cbe
commit
a36eb377db
@ -98,6 +98,14 @@ else
|
|||||||
endfunction
|
endfunction
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
function! s:self.win_count() abort
|
||||||
|
if has('nvim') && exists('*nvim_win_get_config')
|
||||||
|
return len(filter(range(1, winnr('$')), '!has_key(nvim_win_get_config(win_getid(v:val)), "col")'))
|
||||||
|
else
|
||||||
|
return winnr('$')
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:self.winexists(winid) abort
|
function! s:self.winexists(winid) abort
|
||||||
if !exists('win_id2tabwin')
|
if !exists('win_id2tabwin')
|
||||||
return 0
|
return 0
|
||||||
|
@ -37,7 +37,8 @@ let s:LANG = SpaceVim#api#import('language')
|
|||||||
|
|
||||||
let s:JSON = SpaceVim#api#import('data#json')
|
let s:JSON = SpaceVim#api#import('data#json')
|
||||||
|
|
||||||
let s:VIM = SpaceVim#api#import('vim')
|
let s:VIM = SpaceVim#api#import('vim')
|
||||||
|
let s:WIN = SpaceVim#api#import('vim#window')
|
||||||
|
|
||||||
|
|
||||||
" init
|
" init
|
||||||
@ -834,7 +835,7 @@ function! SpaceVim#layers#core#statusline#ctrlp_status(str) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! SpaceVim#layers#core#statusline#jump(i) abort
|
function! SpaceVim#layers#core#statusline#jump(i) abort
|
||||||
if winnr('$') >= a:i
|
if s:WIN.win_count() >= a:i
|
||||||
exe a:i . 'wincmd w'
|
exe a:i . 'wincmd w'
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -11,6 +11,7 @@ scriptencoding utf-8
|
|||||||
let s:SYS = SpaceVim#api#import('system')
|
let s:SYS = SpaceVim#api#import('system')
|
||||||
let s:FILE = SpaceVim#api#import('file')
|
let s:FILE = SpaceVim#api#import('file')
|
||||||
let s:VCOP = SpaceVim#api#import('vim#compatible')
|
let s:VCOP = SpaceVim#api#import('vim#compatible')
|
||||||
|
let s:WIN = SpaceVim#api#import('vim#window')
|
||||||
|
|
||||||
if g:spacevim_filetree_direction ==# 'right'
|
if g:spacevim_filetree_direction ==# 'right'
|
||||||
let s:direction = 'rightbelow'
|
let s:direction = 'rightbelow'
|
||||||
@ -61,19 +62,11 @@ augroup vfinit
|
|||||||
autocmd FileType defx call s:defx_init()
|
autocmd FileType defx call s:defx_init()
|
||||||
" auto close last defx windows
|
" auto close last defx windows
|
||||||
autocmd BufEnter * nested if
|
autocmd BufEnter * nested if
|
||||||
\ (!has('vim_starting') && s:win_count() == 1 && g:_spacevim_autoclose_filetree
|
\ (!has('vim_starting') && s:WIN.win_count() == 1 && g:_spacevim_autoclose_filetree
|
||||||
\ && &filetype ==# 'defx') |
|
\ && &filetype ==# 'defx') |
|
||||||
\ call s:close_last_vimfiler_windows() | endif
|
\ call s:close_last_vimfiler_windows() | endif
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
function! s:win_count() abort
|
|
||||||
if has('nvim') && exists('*nvim_win_get_config')
|
|
||||||
return len(filter(range(1, winnr('$')), '!has_key(nvim_win_get_config(win_getid(v:val)), "col")'))
|
|
||||||
else
|
|
||||||
return winnr('$')
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" in this function, we should check if shell terminal still exists,
|
" in this function, we should check if shell terminal still exists,
|
||||||
" then close the terminal job before close vimfiler
|
" then close the terminal job before close vimfiler
|
||||||
function! s:close_last_vimfiler_windows() abort
|
function! s:close_last_vimfiler_windows() abort
|
||||||
|
Loading…
Reference in New Issue
Block a user