Просмотр исходного кода

Change behavior of Toggle when BufExplorer is open.

1. If BufExplorer is already open in another window, go to it and keep it open.

2. If BufExplorer is already open in the current window, don't call BufExplorer() first, because doing so displays [BufExplorer] in the buffer list when it is opened again.

The root cause of the error appears to be the BufExplorer() function's use of the drop statement. This fix doesn't completely solve the problem, but it does make it much less likely to happen. Now only scenario 1 above will cause the normally-unlisted [BufExplorer] buffer to be displayed in the list.
Phil Runninger 11 лет назад
Родитель
Сommit
040e000de3
1 измененных файлов с 10 добавлено и 5 удалено
  1. 10 5
      plugin/bufexplorer.vim

+ 10 - 5
plugin/bufexplorer.vim

@@ -268,7 +268,7 @@ function! s:ShouldIgnore(buf)
     endif
 
     " Ignore the BufExplorer buffer.
-    if fnamemodify(bufname(a:buf), ":t") == s:name
+    if fnamemodify(bufname(a:buf), ":t") == s:BufExplorerName()
         return 1
     endif
 
@@ -344,22 +344,27 @@ endfunction
 
 " ToggleBufExplorer {{{2
 function! ToggleBufExplorer()
-    if exists("s:running") && s:running == 1
-        call BufExplorer()
+    if exists("s:running") && s:running == 1 && bufname(winbufnr(0)) == s:BufExplorerName()
         call s:Close()
     else
         call BufExplorer()
     endif
 endfunction
 
-" BufExplorer {{{2
-function! BufExplorer()
+" BufexplorerName {{{2
+function! s:BufExplorerName()
     let name = s:name
 
     if !has("win32")
         " On non-Windows boxes, escape the name so that is shows up correctly.
         let name = escape(name, "[]")
     endif
+    return name
+endfunction
+
+" BufExplorer {{{2
+function! BufExplorer()
+    let name = s:BufExplorerName()
 
     " Make sure there is only one explorer open at a time.
     if s:running == 1