Browse Source

If BufExplorer is already running, switch to it.

This uses `:tabnext` and `wincmd w` to allow use in non-GUI editors.
Michael Henry 9 months ago
parent
commit
1be0f8c70f
1 changed files with 7 additions and 10 deletions
  1. 7 10
      plugin/bufexplorer.vim

+ 7 - 10
plugin/bufexplorer.vim

@@ -582,6 +582,13 @@ endfunction
 
 " BufExplorer {{{2
 function! BufExplorer()
+    let [tabNbr, winNbr] = s:FindBufExplorer()
+    if tabNbr > 0
+        execute 'keepjumps ' . tabNbr . 'tabnext'
+        execute 'keepjumps ' . winNbr . 'wincmd w'
+        return
+    endif
+
     let name = s:name
 
     if !has("win32")
@@ -589,16 +596,6 @@ function! BufExplorer()
         let name = escape(name, "[]")
     endif
 
-    " Make sure there is only one explorer open at a time.
-    if s:running == 1
-        " Go to the open buffer.
-        if has("gui")
-            execute "drop" name
-        endif
-
-        return
-    endif
-
     let s:tabIdAtLaunch = s:MRUEnsureTabId(tabpagenr())
     let s:windowAtLaunch = winnr()