|
1 | | -" Public API for vim-notes plug-in. |
| 1 | +" Public API for the vim-notes plug-in. |
2 | 2 | " |
3 | 3 | " Author: Peter Odding |
4 | 4 | " Last Change: June 24, 2013 |
5 | 5 | " URL: http://peterodding.com/code/vim/session/ |
6 | 6 |
|
7 | | -let g:xolox#session#version = '2.4.3' |
| 7 | +let g:xolox#session#version = '2.4.4' |
8 | 8 |
|
9 | 9 | " Public API for session persistence. {{{1 |
10 | 10 |
|
11 | | -" The functions in this fold take a single list argument in which the Vim |
12 | | -" script lines are stored that should be executed to restore the (relevant |
13 | | -" parts of the) current Vim editing session. The only exception to this is |
14 | | -" xolox#session#save_session() which expects the target filename as 2nd |
15 | | -" argument: |
16 | | - |
17 | 11 | function! xolox#session#save_session(commands, filename) " {{{2 |
18 | 12 | " Save the current Vim editing session to a Vim script using the |
19 | 13 | " [:mksession] [] command and some additional Vim magic provided by the |
@@ -193,6 +187,15 @@ function! xolox#session#save_state(commands) " {{{2 |
193 | 187 | call map(lines, 's:tabpage_filter(buffers, v:val)') |
194 | 188 | endif |
195 | 189 | call extend(a:commands, map(lines, 's:state_filter(v:val)')) |
| 190 | + " Re-implement Vim's special handling of the initial, empty buffer. |
| 191 | + call add(a:commands, "if exists('s:wipebuf')") |
| 192 | + call add(a:commands, " if empty(bufname(s:wipebuf)) && !getbufvar(s:wipebuf, '&modified')") |
| 193 | + call add(a:commands, " let s:wipebuflines = getbufline(s:wipebuf, 1, '$')") |
| 194 | + call add(a:commands, " if len(s:wipebuflines) <= 1 && empty(get(s:wipebuflines, 0, ''))") |
| 195 | + call add(a:commands, " silent exe 'bwipe ' . s:wipebuf") |
| 196 | + call add(a:commands, " endif") |
| 197 | + call add(a:commands, " endif") |
| 198 | + call add(a:commands, "endif") |
196 | 199 | return 1 |
197 | 200 | finally |
198 | 201 | let &sessionoptions = ssop_save |
@@ -252,7 +255,7 @@ function! s:state_filter(line) " {{{3 |
252 | 255 | " when :mksession adds corresponding :argglobal and/or :argument commands |
253 | 256 | " to the session script. |
254 | 257 | return '" ' . a:line |
255 | | - elseif a:line =~ "^\\s*silent exe 'bwipe ' \\. s:wipebuf$" |
| 258 | + elseif a:line =~ "^\\s*silent exe 'bwipe ' \\. s:wipebuf$" || a:line =~ '^unlet! s:wipebuf$' |
256 | 259 | " Disable Vim's special handling of the initial, empty buffer because it |
257 | 260 | " breaks restoring of special windows with content generated by a Vim |
258 | 261 | " plug-in. The :mksession command doesn't have this problem because it |
|
0 commit comments