Преглед изворни кода

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.