فهرست منبع

when quitting the bufexplorer window using the 'q' mapping, switch to
the previously active buffer rather than the first buffer in the list
also, preserve the correct alt buffer so that <C-^> works.

halfmanhalffish 11 سال پیش
والد
کامیت
587d7f50d7
1فایلهای تغییر یافته به همراه10 افزوده شده و 3 حذف شده
  1. 10 3
      plugin/bufexplorer.vim

+ 10 - 3
plugin/bufexplorer.vim

@@ -112,6 +112,8 @@ let s:sort_by = ["number", "name", "fullpath", "mru", "extension"]
 let s:splitMode = ""
 let s:tabSpace = []
 let s:types = {"fullname": ':p', "path": ':p:h', "relativename": ':~:.', "relativepath": ':~:.:h', "shortname": ':t'}
+let s:altBufferOnEntry = ""
+let s:activeBufferOnEntry = ""
 
 " Setup the autocommands that handle the MRUList and other stuff. {{{2
 autocmd VimEnter * call s:Setup()
@@ -683,6 +685,12 @@ function! s:BuildBufferList()
             endif
         endif
 
+        if buf.attributes =~ "%"
+            let s:activeBufferOnEntry = matchstr(buf.attributes, '[0-9]\+')
+        elseif buf.attributes =~ "#"
+            let s:altBufferOnEntry =  matchstr(buf.attributes, '[0-9]\+')
+        endif
+
         let line = buf.attributes." "
 
         " Are we to split the path and file name?
@@ -916,9 +924,8 @@ function! s:Close()
     else
         " Since there are buffers left to switch to, swith to the previous and
         " then the current.
-        for b in reverse(listed[0:1])
-            execute "keepjumps silent b ".b
-        endfor
+        execute "keepjumps silent b ".s:altBufferOnEntry
+        execute "keepjumps silent b ".s:activeBufferOnEntry
     endif
 
     " Clear any messages.