Skip to content

Commit

Permalink
Bug fix: Re-implement Vim's special handling of initial, empty buffer
Browse files Browse the repository at this point in the history
See issue #60 on GitHub:
  #60

This is a follow up to my recent changes for issue #28:

  Bug fix: Disable Vim's special handling of initial, empty buffer
  #28
  • Loading branch information
xolox committed Jun 24, 2013
1 parent 74e5034 commit d5c3b6a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -236,9 +236,9 @@ Recently this plug-in switched from reimplementing [:mksession][mksession] to ac
<!-- Start of generated documentation -->

The documentation of the 34 functions below was extracted from
2 Vim scripts on June 24, 2013 at 22:49.
1 Vim scripts on June 24, 2013 at 23:47.

### Public API for vim-notes plug-in
### Public API for the vim-notes plug-in

#### The `xolox#session#save_session()` function

Expand Down
21 changes: 12 additions & 9 deletions autoload/xolox/session.vim
@@ -1,19 +1,13 @@
" Public API for vim-notes plug-in.
" Public API for the vim-notes plug-in.
"
" Author: Peter Odding
" Last Change: June 24, 2013
" URL: http://peterodding.com/code/vim/session/

let g:xolox#session#version = '2.4.3'
let g:xolox#session#version = '2.4.4'

" Public API for session persistence. {{{1

" The functions in this fold take a single list argument in which the Vim
" script lines are stored that should be executed to restore the (relevant
" parts of the) current Vim editing session. The only exception to this is
" xolox#session#save_session() which expects the target filename as 2nd
" argument:

function! xolox#session#save_session(commands, filename) " {{{2
" Save the current Vim editing session to a Vim script using the
" [:mksession] [] command and some additional Vim magic provided by the
Expand Down Expand Up @@ -193,6 +187,15 @@ function! xolox#session#save_state(commands) " {{{2
call map(lines, 's:tabpage_filter(buffers, v:val)')
endif
call extend(a:commands, map(lines, 's:state_filter(v:val)'))
" Re-implement Vim's special handling of the initial, empty buffer.
call add(a:commands, "if exists('s:wipebuf')")
call add(a:commands, " if empty(bufname(s:wipebuf)) && !getbufvar(s:wipebuf, '&modified')")
call add(a:commands, " let s:wipebuflines = getbufline(s:wipebuf, 1, '$')")
call add(a:commands, " if len(s:wipebuflines) <= 1 && empty(get(s:wipebuflines, 0, ''))")
call add(a:commands, " silent exe 'bwipe ' . s:wipebuf")
call add(a:commands, " endif")
call add(a:commands, " endif")
call add(a:commands, "endif")
return 1
finally
let &sessionoptions = ssop_save
Expand Down Expand Up @@ -252,7 +255,7 @@ function! s:state_filter(line) " {{{3
" when :mksession adds corresponding :argglobal and/or :argument commands
" to the session script.
return '" ' . a:line
elseif a:line =~ "^\\s*silent exe 'bwipe ' \\. s:wipebuf$"
elseif a:line =~ "^\\s*silent exe 'bwipe ' \\. s:wipebuf$" || a:line =~ '^unlet! s:wipebuf$'
" Disable Vim's special handling of the initial, empty buffer because it
" breaks restoring of special windows with content generated by a Vim
" plug-in. The :mksession command doesn't have this problem because it
Expand Down
8 changes: 4 additions & 4 deletions doc/session.txt
Expand Up @@ -34,7 +34,7 @@ Contents ~
5. Compatibility with other plug-ins |session-compatibility-with-other-plug-ins|
6. Known issues |session-known-issues|
7. Function reference |session-function-reference|
1. Public API for vim-notes plug-in |session-public-api-for-vim-notes-plug-in|
1. Public API for the vim-notes plug-in |session-public-api-for-vim-notes-plug-in|
1. The |xolox#session#save_session()| function
2. The |xolox#session#save_globals()| function
3. The |xolox#session#save_features()| function
Expand Down Expand Up @@ -476,12 +476,12 @@ might take a while...)
*session-function-reference*
Function reference ~

The documentation of the 34 functions below was extracted from 2 Vim scripts on
June 24, 2013 at 22:49.
The documentation of the 34 functions below was extracted from 1 Vim scripts on
June 24, 2013 at 23:47.

-------------------------------------------------------------------------------
*session-public-api-for-vim-notes-plug-in*
Public API for vim-notes plug-in ~
Public API for the vim-notes plug-in ~

-------------------------------------------------------------------------------
The *xolox#session#save_session()* function
Expand Down

0 comments on commit d5c3b6a

Please sign in to comment.