Browse Source

Fix switching to calling buffer

References #115.
Marco Hinz 11 years ago
parent
commit
d17bc302d4
2 changed files with 9 additions and 15 deletions
  1. 7 13
      autoload/startify.vim
  2. 2 2
      plugin/startify.vim

+ 7 - 13
autoload/startify.vim

@@ -37,7 +37,7 @@ function! startify#get_lastline() abort
 endfunction
 
 " Function: #insane_in_the_membrane {{{1
-function! startify#insane_in_the_membrane(callingbuffer) abort
+function! startify#insane_in_the_membrane() abort
   if &insertmode
     return
   endif
@@ -50,10 +50,6 @@ function! startify#insane_in_the_membrane(callingbuffer) abort
     endfor
   endif
 
-  if a:callingbuffer != 0
-    let s:callingbuffer = a:callingbuffer
-  endif
-
   enew
   set filetype=startify
   setlocal
@@ -234,16 +230,14 @@ endfunction
 function! startify#session_write(spath)
   let ssop = &sessionoptions
   try
-    " if this function was called through :Startify instead of :SLoad
+    " if this function is called while being in the Startify buffer
+    " (by loading another session or running :SSave/:SLoad directly)
     " switch back to the previous buffer before saving the session
-    if exists('s:callingbuffer')
-      redir => callingbuffer
-      file
-      redir END
-      if callingbuffer !~# '\[No Name\]'
-        execute 'buffer' s:callingbuffer
+    if &filetype == 'startify'
+      let callingbuffer = bufnr('#')
+      if callingbuffer > 0
+        execute 'buffer' callingbuffer
       endif
-      unlet s:callingbuffer
     endif
     " prevent saving already deleted buffers that were in the arglist
     for arg in argv()

+ 2 - 2
plugin/startify.vim

@@ -14,7 +14,7 @@ augroup startify
   if !get(g:, 'startify_disable_at_vimenter')
     autocmd VimEnter *
           \   if !argc() && (line2byte('$') == -1) && (v:progname =~? '^[gmnq]\=vim\=x\=\%[\.exe]$')
-          \ |   call startify#insane_in_the_membrane(0)
+          \ |   call startify#insane_in_the_membrane()
           \ | endif
           \ | autocmd! startify VimEnter
   endif
@@ -30,4 +30,4 @@ augroup END
 command! -nargs=? -bar -complete=customlist,startify#session_list SSave   call startify#session_save(<f-args>)
 command! -nargs=? -bar -complete=customlist,startify#session_list SLoad   call startify#session_load(<f-args>)
 command! -nargs=? -bar -complete=customlist,startify#session_list SDelete call startify#session_delete(<f-args>)
-command! -nargs=0 -bar Startify call startify#insane_in_the_membrane(bufnr('%'))
+command! -nargs=0 -bar Startify call startify#insane_in_the_membrane()