Skip to content

Commit 8cc18f0

Browse files
committed
Make it easier to save a session for the 1st time (issues #19, #25)
Issue #19: #19 Issue #21: #25
1 parent 7d2a45c commit 8cc18f0

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

autoload/xolox/session.vim

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
" Vim script
22
" Author: Peter Odding
3-
" Last Change: May 3, 2013
3+
" Last Change: May 4, 2013
44
" URL: http://peterodding.com/code/vim/session/
55

6-
let g:xolox#session#version = '1.7.1'
6+
let g:xolox#session#version = '1.7.2'
77

88
call xolox#misc#compat#check('session', 2)
99

@@ -286,13 +286,26 @@ function! xolox#session#auto_load() " {{{2
286286
endfunction
287287

288288
function! xolox#session#auto_save() " {{{2
289-
if !v:dying && g:session_autosave != 'no'
290-
let name = s:get_name('', 0)
291-
if name != ''
292-
let msg = "Do you want to save your editing session before quitting Vim?"
293-
if s:prompt(msg, ['&Yes', '&No'], 'g:session_autosave') == 1
294-
call xolox#session#save_cmd(name, '')
295-
endif
289+
" We won't save the session if Vim is not terminating normally.
290+
if v:dying
291+
return
292+
endif
293+
" We won't save the session if auto-save is explicitly disabled.
294+
if g:session_autosave == 'no'
295+
return
296+
endif
297+
" Get the name of the active session (if any).
298+
let name = s:get_name('', 0)
299+
" If no session is active and the user doesn't have any sessions yet, help
300+
" them get started by suggesting to create the default session.
301+
if empty(name) && empty(xolox#session#get_names())
302+
let name = g:session_default_name
303+
endif
304+
" Prompt the user to save the active or first session?
305+
if !empty(name)
306+
let msg = "Do you want to save your editing session before quitting Vim?"
307+
if s:prompt(msg, ['&Yes', '&No'], 'g:session_autosave') == 1
308+
call xolox#session#save_cmd(name, '')
296309
endif
297310
endif
298311
endfunction

0 commit comments

Comments
 (0)