summaryrefslogtreecommitdiff
path: root/src/testdir/test_mksession.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-03-09 21:33:34 +0100
committerBram Moolenaar <Bram@vim.org>2018-03-09 21:33:34 +0100
commit4d8bac8bf593ff087517ff79090c2d224325aae6 (patch)
tree51e277a9012731df3a3dc362af5c5db39991485a /src/testdir/test_mksession.vim
parent20586cb4f4d516a60b96cc02a94b810fea8b8cdb (diff)
downloadvim-git-4d8bac8bf593ff087517ff79090c2d224325aae6.tar.gz
patch 8.0.1592: terminal windows in a session are not properly restoredv8.0.1592
Problem: Terminal windows in a session are not properly restored. Solution: Add "terminal" in 'sessionoptions'. When possible restore the command running in a terminal.
Diffstat (limited to 'src/testdir/test_mksession.vim')
-rw-r--r--src/testdir/test_mksession.vim104
1 files changed, 104 insertions, 0 deletions
diff --git a/src/testdir/test_mksession.vim b/src/testdir/test_mksession.vim
index cdb6f4caf..81883b5d7 100644
--- a/src/testdir/test_mksession.vim
+++ b/src/testdir/test_mksession.vim
@@ -7,6 +7,8 @@ if !has('multi_byte') || !has('mksession')
finish
endif
+source shared.vim
+
func Test_mksession()
tabnew
let wrap_save = &wrap
@@ -99,6 +101,7 @@ func Test_mksession()
call delete('Xtest_mks.out')
call delete(tmpfile)
let &wrap = wrap_save
+ set sessionoptions&
endfunc
func Test_mksession_winheight()
@@ -150,6 +153,107 @@ func Test_mksession_one_buffer_two_windows()
call delete('Xtest_mks.out')
endfunc
+if has('terminal')
+
+func Test_mksession_terminal_shell()
+ terminal
+ mksession! Xtest_mks.out
+ let lines = readfile('Xtest_mks.out')
+ let term_cmd = ''
+ for line in lines
+ if line =~ '^terminal'
+ let term_cmd = line
+ elseif line =~ 'badd.*' . &shell
+ call assert_report('unexpected shell line: ' . line)
+ endif
+ endfor
+ call assert_match('terminal ++curwin ++cols=\d\+ ++rows=\d\+\s*$', term_cmd)
+
+ call Stop_shell_in_terminal(bufnr('%'))
+ call delete('Xtest_mks.out')
+endfunc
+
+func Test_mksession_terminal_no_restore_cmdarg()
+ terminal ++norestore
+ mksession! Xtest_mks.out
+ let lines = readfile('Xtest_mks.out')
+ let term_cmd = ''
+ for line in lines
+ if line =~ '^terminal'
+ call assert_report('session must not restore teminal')
+ endif
+ endfor
+
+ call Stop_shell_in_terminal(bufnr('%'))
+ call delete('Xtest_mks.out')
+endfunc
+
+func Test_mksession_terminal_no_restore_funcarg()
+ call term_start(&shell, {'norestore': 1})
+ mksession! Xtest_mks.out
+ let lines = readfile('Xtest_mks.out')
+ let term_cmd = ''
+ for line in lines
+ if line =~ '^terminal'
+ call assert_report('session must not restore teminal')
+ endif
+ endfor
+
+ call Stop_shell_in_terminal(bufnr('%'))
+ call delete('Xtest_mks.out')
+endfunc
+
+func Test_mksession_terminal_no_restore_func()
+ terminal
+ call term_setrestore(bufnr('%'), 'NONE')
+ mksession! Xtest_mks.out
+ let lines = readfile('Xtest_mks.out')
+ let term_cmd = ''
+ for line in lines
+ if line =~ '^terminal'
+ call assert_report('session must not restore teminal')
+ endif
+ endfor
+
+ call Stop_shell_in_terminal(bufnr('%'))
+ call delete('Xtest_mks.out')
+endfunc
+
+func Test_mksession_terminal_no_ssop()
+ terminal
+ set sessionoptions-=terminal
+ mksession! Xtest_mks.out
+ let lines = readfile('Xtest_mks.out')
+ let term_cmd = ''
+ for line in lines
+ if line =~ '^terminal'
+ call assert_report('session must not restore teminal')
+ endif
+ endfor
+
+ call Stop_shell_in_terminal(bufnr('%'))
+ call delete('Xtest_mks.out')
+ set sessionoptions&
+endfunc
+
+func Test_mksession_terminal_restore_other()
+ terminal
+ call term_setrestore(bufnr('%'), 'other')
+ mksession! Xtest_mks.out
+ let lines = readfile('Xtest_mks.out')
+ let term_cmd = ''
+ for line in lines
+ if line =~ '^terminal'
+ let term_cmd = line
+ endif
+ endfor
+ call assert_match('terminal ++curwin ++cols=\d\+ ++rows=\d\+ other', term_cmd)
+
+ call Stop_shell_in_terminal(bufnr('%'))
+ call delete('Xtest_mks.out')
+endfunc
+
+endif " has('terminal')
" vim: shiftwidth=2 sts=2 expandtab