" Test for :mksession, :mkview and :loadview in latin1 encoding
set encoding=latin1
scriptencoding latin1
source check.vim
CheckFeature mksession
source shared.vim
source term_util.vim
" Test for storing global and local argument list in a session file
" This one must be done first.
func Test__mksession_arglocal()
enew | only
n a b c
new
arglocal
mksession! Xtest_mks.out
%bwipe!
%argdelete
argglobal
source Xtest_mks.out
call assert_equal(2, winnr('$'))
call assert_equal(2, arglistid(1))
call assert_equal(0, arglistid(2))
%bwipe!
%argdelete
argglobal
call delete('Xtest_mks.out')
endfunc
func Test_mksession()
tabnew
let wrap_save = &wrap
set sessionoptions=buffers splitbelow fileencoding=latin1
call setline(1, [
\ 'start:',
\ 'no multibyte chAracter',
\ ' one leaDing tab',
\ ' four leadinG spaces',
\ 'two consecutive tabs',
\ 'two tabs in one line',
\ 'one � multibyteCharacter',
\ 'a� � two multiByte characters',
\ 'A��� three mulTibyte characters',
\ 'short line',
\ ])
let tmpfile = 'Xtemp'
exec 'w! ' . tmpfile
/^start:
set wrap
vsplit
norm! j16|
split
norm! j16|
split
norm! j16|
split
norm! j8|
split
norm! j8|
split
norm! j16|
split
norm! j16|
split
norm! j16|
split
norm! j$
wincmd l
set nowrap
/^start:
norm! j16|3zl
split
norm! j016|3zl
split
norm! j016|3zl
split
norm! j08|3zl
split
norm! j08|3zl
split
norm! j016|3zl
split
norm! j016|3zl
split
norm! j016|3zl
split
call wincol()
mksession! Xtest_mks.out
let li = filter(readfile('Xtest_mks.out'), 'v:val =~# "\\(^ *normal! [0$]\\|^ *exe ''normal!\\)"')
let expected = [
\ 'normal! 016|',
\ 'normal! 016|',
\ 'normal! 016|',
\ 'normal! 08|',
\ 'normal! 08|',
\ 'normal! 016|',
\ 'normal! 016|',
\ 'normal! 016|',
\ 'normal! $',
\ " exe 'normal! ' . s:c . '|zs' . 16 . '|'",
\ " normal! 016|",
\ " exe 'normal! ' . s:c . '|zs' . 16 . '|'",
\ " normal! 016|",
\ " exe 'normal! ' . s:c . '|zs' . 16 . '|'",
\ " normal! 016|",
\ " exe 'normal! ' . s:c . '|zs' . 8 . '|'",
\ " normal! 08|",
\ " exe 'normal! ' . s:c . '|zs' . 8 . '|'",
\ " normal! 08|",
\ " exe 'normal! ' . s:c . '|zs' . 16 . '|'",
\ " normal! 016|",
\ " exe 'normal! ' . s:c . '|zs' . 16 . '|'",
\ " normal! 016|",
\ " exe 'normal! ' . s:c . '|zs' . 16 . '|'",
\ " normal! 016|",
\ " exe 'normal! ' . s:c . '|zs' . 16 . '|'",
\ " normal! 016|"
\ ]
call assert_equal(expected, li)
tabclose!
call delete('Xtest_mks.out')
call delete(tmpfile)
let &wrap = wrap_save
set sessionoptions&
endfunc
def Test_mksession_skiprtp()
mksession! Xtest_mks.out
var found_rtp = 0
var found_pp = 0
for line in readfile('Xtest_mks.out')
if line =~ 'set runtimepath'
found_rtp += 1
endif
if line =~ 'set packpath'
found_pp += 1
endif
endfor
assert_equal(1, found_rtp)
assert_equal(1, found_pp)
delete('Xtest_mks.out')
set sessionoptions+=skiprtp
mksession! Xtest_mks.out
var found = 0
for line in readfile('Xtest_mks.out')
if line =~ 'set \(runtimepath\|packpath\)'
found = 1
break
endif
endfor
assert_equal(0, found)
delete('Xtest_mks.out')
set sessionoptions&
enddef
func Test_mksession_winheight()
new
set winheight=10
set winminheight=2
mksession! Xtest_mks.out
source Xtest_mks.out
call delete('Xtest_mks.out')
endfunc
func Test_mksession_large_winheight()
set winheight=999
mksession! Xtest_mks_winheight.out
set winheight&
source Xtest_mks_winheight.out
call delete('Xtest_mks_winheight.out')
endfunc
func Test_mksession_zero_winheight()
set winminheight=0
edit SomeFile
split
wincmd _