From a2f1ea481da9e5adb572de5faf7d27567dbed34e Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 9 Oct 2016 04:29:39 +0900 Subject: [PATCH] Reuse existing plug window Close #532 --- plug.vim | 8 ++++++-- test/workflow.vader | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/plug.vim b/plug.vim index 1da64a9..2b7fc34 100644 --- a/plug.vim +++ b/plug.vim @@ -726,10 +726,14 @@ function! s:prepare(...) call s:job_abort() if s:switch_in() - normal q + if b:plug_preview == 1 + pc + endif + enew + else + call s:new_window() endif - call s:new_window() nnoremap q :if b:plug_preview==1pcendifbd if a:0 == 0 call s:finish_bindings() diff --git a/test/workflow.vader b/test/workflow.vader index bb062dc..4062eae 100644 --- a/test/workflow.vader +++ b/test/workflow.vader @@ -1520,3 +1520,24 @@ Execute (#530 - Comparison of incompatible git URIs): " Different port Assert !CompareURI('https://github.com/junegunn/vim-plug.git', 'https://github.com:12345/junegunn/vim-plug.git') + +Execute (#532 - Reuse plug window): + PlugDiff + AssertEqual 1, winnr() + AssertEqual 2, winnr('$') + + " Open preview window + execute "normal ]]jo" + AssertEqual 2, winnr() + AssertEqual 3, winnr('$') + + " Move plug window to the right + wincmd L + AssertEqual 3, winnr() + AssertEqual 3, winnr('$') + + " Reuse plug window. Preview window is closed. + PlugStatus + AssertEqual 2, winnr() + AssertEqual 2, winnr('$') + q