|
1 | 1 | " Vim script
|
2 | 2 | " Author: Peter Odding
|
3 |
| -" Last Change: May 3, 2013 |
| 3 | +" Last Change: May 4, 2013 |
4 | 4 | " URL: http://peterodding.com/code/vim/session/
|
5 | 5 |
|
6 |
| -let g:xolox#session#version = '1.7.1' |
| 6 | +let g:xolox#session#version = '1.7.2' |
7 | 7 |
|
8 | 8 | call xolox#misc#compat#check('session', 2)
|
9 | 9 |
|
@@ -286,13 +286,26 @@ function! xolox#session#auto_load() " {{{2
|
286 | 286 | endfunction
|
287 | 287 |
|
288 | 288 | 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, '') |
296 | 309 | endif
|
297 | 310 | endif
|
298 | 311 | endfunction
|
|
0 commit comments