Marco Hinz 10 лет назад
Родитель
Сommit
7994cae378
4 измененных файлов с 19 добавлено и 11 удалено
  1. 10 4
      autoload/startify.vim
  2. 6 4
      doc/startify.txt
  3. 1 1
      plugin/startify.vim
  4. 2 2
      test/feature/session.vader

+ 10 - 4
autoload/startify.vim

@@ -309,7 +309,7 @@ function! startify#session_write(spath)
 endfunction
 
 " Function: #session_delete {{{1
-function! startify#session_delete(...) abort
+function! startify#session_delete(bang, ...) abort
   if !isdirectory(s:session_dir)
     echo 'The session directory does not exist: '. s:session_dir
     return
@@ -326,7 +326,7 @@ function! startify#session_delete(...) abort
   call inputrestore()
 
   echo 'Really delete '. spath .'? [y/n]' | redraw
-  if (nr2char(getchar()) == 'y')
+  if a:bang || nr2char(getchar()) == 'y'
     if delete(spath) == 0
       echo 'Deleted session '. spath .'!'
     else
@@ -338,14 +338,20 @@ function! startify#session_delete(...) abort
 endfunction
 
 " Function: #session_delete_buffers {{{1
-function! startify#session_delete_buffers() abort
+function! startify#session_delete_buffers()
   if !s:delete_buffers
     return
   endif
   let n = 1
   while n <= bufnr('$')
     if buflisted(n)
-      silent execute 'bdelete' n
+      try
+        silent execute 'bdelete' n
+      catch
+        echohl ErrorMsg
+        echomsg v:exception
+        echohl NONE
+      endtry
     endif
     let n += 1
   endwhile

+ 6 - 4
doc/startify.txt

@@ -76,10 +76,12 @@ Startify basically provides two things:
 2) It eases handling of loading and saving sessions by only working with a
    certain directory. These commands are used for convenience:
 
-      :SLoad    load a session
-      :SSave    save a session
-      :SDelete  delete a session
-      :SClose   close a session
+      :SLoad       load a session
+      :SSave       save a session
+      :SDelete[!]  delete a session
+      :SClose      close a session
+
+    If ! is given, you won't get prompted.
 
 ==============================================================================
 OPTIONS                                                       *startify-options*

+ 1 - 1
plugin/startify.vim

@@ -55,7 +55,7 @@ endfunction
 
 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=? -bar -bang -complete=customlist,startify#session_list SDelete call startify#session_delete(<bang>0, <f-args>)
 command! -nargs=0 -bar SClose call startify#session_close()
 command! -nargs=0 -bar Startify enew | call startify#insane_in_the_membrane()
 command! -nargs=0 -bar StartifyDebug call startify#debug()

+ 2 - 2
test/feature/session.vader

@@ -12,7 +12,7 @@ Expect:
   This is just a simple test file.
   Foo, bar, quux.
 
-Execute (Session: :SDelete foo):
+Execute (Session: :SDelete! foo):
   Assert 1 == filereadable(g:startify_session_dir.'/foo')
-  SDelete foo
+  SDelete! foo
   Assert 0 == filereadable(g:startify_session_dir.'/foo')