diff --git a/autoload/xolox/session.vim b/autoload/xolox/session.vim index 165a39e..47d77d5 100644 --- a/autoload/xolox/session.vim +++ b/autoload/xolox/session.vim @@ -1,9 +1,9 @@ " Vim script " Author: Peter Odding -" Last Change: April 18, 2013 +" Last Change: April 20, 2013 " URL: http://peterodding.com/code/vim/session/ -let g:xolox#session#version = '1.5.2' +let g:xolox#session#version = '1.5.3' " Public API for session persistence. {{{1 @@ -263,7 +263,7 @@ endfunction function! xolox#session#auto_save() " {{{2 if !v:dying && g:session_autosave != 'no' let name = s:get_name('', 0) - if name != '' && exists('s:session_is_dirty') + if name != '' let msg = "Do you want to save your editing session before quitting Vim?" if s:prompt(msg, 'g:session_autosave') execute 'SaveSession' fnameescape(name) @@ -284,66 +284,6 @@ function! xolox#session#auto_unlock() " {{{2 endwhile endfunction -function! xolox#session#auto_dirty_check() " {{{2 - " TODO Why execute this on every buffer change?! Instead execute it only when we want to know whether the session is dirty! - " This function is called each time a BufEnter event fires to detect when - " the current tab page (or the buffer list) is changed in some way. This - " enables the plug-in to not bother with the auto-save dialog when the - " session hasn't changed. - if v:this_session == '' - " Don't waste CPU time when no session is loaded. - return - elseif !exists('s:cached_layouts') - let s:cached_layouts = {} - else - " Clear non-existing tab pages from s:cached_layouts. - let last_tabpage = tabpagenr('$') - call filter(s:cached_layouts, 'v:key <= last_tabpage') - endif - " Check the buffer list. - let all_buffers = s:serialize_buffer_list() - if all_buffers != get(s:cached_layouts, 0, '') - let s:session_is_dirty = 1 - endif - let s:cached_layouts[0] = all_buffers - " Check the layout of the current tab page. - let tabpagenr = tabpagenr() - let keys = ['tabpage:' . tabpagenr] - let buflist = tabpagebuflist() - for winnr in range(1, winnr('$')) - " Create a string that describes the state of the window {winnr}. - call add(keys, printf('width:%i,height:%i,buffer:%i', - \ winwidth(winnr), winheight(winnr), buflist[winnr - 1])) - endfor - let layout = join(keys, "\n") - if layout != get(s:cached_layouts, tabpagenr, '') - let s:session_is_dirty = 1 - endif - let s:cached_layouts[tabpagenr] = layout -endfunction - -function! s:serialize_buffer_list() - if &sessionoptions =~ '\' - return join(map(range(1, bufnr('$')), 's:serialize_buffer_state(v:val)'), "\n") - endif - return '' -endfunction - -function! s:serialize_buffer_state(bufnr) - " TODO ssop =~ '\' ? - let bufname = bufname(a:bufnr) - if bufname =~ '^NERD_tree_\d\+$' - " TODO I thought this would work, but somehow it doesn't?! - let root = getbufvar(a:bufnr, 'b:NERDTreeRoot') - if !empty(root) - let bufname = root.path.str() . '/' . bufname - endif - elseif bufname != '' - let bufname = fnamemodify(bufname, ':p') - endif - return a:bufnr . ':' . bufname -endfunction - " Commands that enable users to manage multiple sessions. {{{1 function! s:prompt(msg, var) @@ -372,7 +312,6 @@ function! xolox#session#open_cmd(name, bang) abort " {{{2 let s:oldcwd = oldcwd call s:lock_session(path) execute 'source' fnameescape(path) - unlet! s:session_is_dirty call s:last_session_persist(name) call xolox#misc#timer#stop("session.vim %s: Opened %s session in %s.", g:xolox#session#version, string(name), starttime) call xolox#misc#msg#info("session.vim %s: Opened %s session from %s.", g:xolox#session#version, string(name), fnamemodify(path, ':~')) @@ -414,7 +353,6 @@ function! xolox#session#save_cmd(name, bang) abort " {{{2 call xolox#misc#msg#info("session.vim %s: Saved %s session to %s.", g:xolox#session#version, string(name), friendly_path) let v:this_session = path call s:lock_session(path) - unlet! s:session_is_dirty endif endif endfunction @@ -441,7 +379,7 @@ endfunction function! xolox#session#close_cmd(bang, silent) abort " {{{2 let name = s:get_name('', 0) - if name != '' && exists('s:session_is_dirty') + if name != '' let msg = "Do you want to save your current editing session before closing it?" if s:prompt(msg, 'g:session_autosave') SaveSession @@ -470,7 +408,6 @@ function! xolox#session#close_cmd(bang, silent) abort " {{{2 execute s:oldcwd unlet s:oldcwd endif - unlet! s:session_is_dirty if v:this_session == '' if !a:silent let msg = "session.vim %s: Closed session." diff --git a/plugin/session.vim b/plugin/session.vim index b9b1d53..6a8aba7 100644 --- a/plugin/session.vim +++ b/plugin/session.vim @@ -1,6 +1,6 @@ " Vim script " Author: Peter Odding -" Last Change: December 11, 2011 +" Last Change: April 20, 2013 " URL: http://peterodding.com/code/vim/session/ " Support for automatic update using the GLVS plug-in. @@ -79,7 +79,6 @@ augroup PluginSession au VimEnter * nested call xolox#session#auto_load() au VimLeavePre * call xolox#session#auto_save() au VimLeavePre * call xolox#session#auto_unlock() - au BufEnter * call xolox#session#auto_dirty_check() augroup END " Define commands that enable users to manage multiple named sessions.