Add GV.vim-style q mapping (#827)
* Add GV.vim-style q mapping * Fix test cases Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
This commit is contained in:
parent
8b45742540
commit
cffcfe150b
2 changed files with 20 additions and 2 deletions
11
plug.vim
11
plug.vim
|
@ -935,7 +935,7 @@ function! s:prepare(...)
|
||||||
call s:new_window()
|
call s:new_window()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
nnoremap <silent> <buffer> q :if b:plug_preview==1<bar>pc<bar>endif<bar>bd<cr>
|
nnoremap <silent> <buffer> q :call <SID>close_pane()<cr>
|
||||||
if a:0 == 0
|
if a:0 == 0
|
||||||
call s:finish_bindings()
|
call s:finish_bindings()
|
||||||
endif
|
endif
|
||||||
|
@ -957,6 +957,15 @@ function! s:prepare(...)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:close_pane()
|
||||||
|
if b:plug_preview == 1
|
||||||
|
pc
|
||||||
|
let b:plug_preview = -1
|
||||||
|
else
|
||||||
|
bd
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:assign_name()
|
function! s:assign_name()
|
||||||
" Assign buffer name
|
" Assign buffer name
|
||||||
let prefix = '[Plugins]'
|
let prefix = '[Plugins]'
|
||||||
|
|
|
@ -428,13 +428,17 @@ Execute (New commits on remote, PlugUpdate, then PlugDiff):
|
||||||
execute "normal Xy\<cr>"
|
execute "normal Xy\<cr>"
|
||||||
AssertExpect '^- ', 1
|
AssertExpect '^- ', 1
|
||||||
|
|
||||||
" q will close preview window as well
|
" q will only close preview window
|
||||||
normal q
|
normal q
|
||||||
|
|
||||||
" We no longer have preview window
|
" We no longer have preview window
|
||||||
silent! wincmd P
|
silent! wincmd P
|
||||||
AssertEqual 0, &previewwindow
|
AssertEqual 0, &previewwindow
|
||||||
|
|
||||||
|
" And we're still on main vim-plug window
|
||||||
|
AssertEqual 'vim-plug', &filetype
|
||||||
|
normal q
|
||||||
|
|
||||||
" q should not close preview window if it's already open
|
" q should not close preview window if it's already open
|
||||||
pedit
|
pedit
|
||||||
PlugDiff
|
PlugDiff
|
||||||
|
@ -459,6 +463,11 @@ Execute (Test g:plug_pwindow):
|
||||||
AssertEqual 2, winnr()
|
AssertEqual 2, winnr()
|
||||||
AssertEqual 5, winheight('.')
|
AssertEqual 5, winheight('.')
|
||||||
wincmd p
|
wincmd p
|
||||||
|
|
||||||
|
" Close preview window
|
||||||
|
normal q
|
||||||
|
|
||||||
|
" Close main window
|
||||||
normal q
|
normal q
|
||||||
unlet g:plug_pwindow
|
unlet g:plug_pwindow
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue