From cffcfe150bda75177920530c5f1911b52f70a065 Mon Sep 17 00:00:00 2001 From: Rosen Stoyanov Date: Mon, 8 Feb 2021 09:23:21 +0200 Subject: [PATCH] Add GV.vim-style q mapping (#827) * Add GV.vim-style q mapping * Fix test cases Co-authored-by: Junegunn Choi --- plug.vim | 11 ++++++++++- test/workflow.vader | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/plug.vim b/plug.vim index 9c296ac..2b89b5a 100644 --- a/plug.vim +++ b/plug.vim @@ -935,7 +935,7 @@ function! s:prepare(...) call s:new_window() endif - nnoremap q :if b:plug_preview==1pcendifbd + nnoremap q :call close_pane() if a:0 == 0 call s:finish_bindings() endif @@ -957,6 +957,15 @@ function! s:prepare(...) endif endfunction +function! s:close_pane() + if b:plug_preview == 1 + pc + let b:plug_preview = -1 + else + bd + endif +endfunction + function! s:assign_name() " Assign buffer name let prefix = '[Plugins]' diff --git a/test/workflow.vader b/test/workflow.vader index f9ab383..8423b86 100644 --- a/test/workflow.vader +++ b/test/workflow.vader @@ -428,13 +428,17 @@ Execute (New commits on remote, PlugUpdate, then PlugDiff): execute "normal Xy\" AssertExpect '^- ', 1 - " q will close preview window as well + " q will only close preview window normal q " We no longer have preview window silent! wincmd P 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 pedit PlugDiff @@ -459,6 +463,11 @@ Execute (Test g:plug_pwindow): AssertEqual 2, winnr() AssertEqual 5, winheight('.') wincmd p + + " Close preview window + normal q + + " Close main window normal q unlet g:plug_pwindow