aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-11-13 13:18:20 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-11-13 13:22:54 +0800
commit4872e2da3cad407f0f45dbb5cc75d0c67743ad22 (patch)
treebd0d7c433f2ed2a7b3aaa2c3a85bf6046559a3b1
parent748eae6bb59be742fddec587f9f8171d9d0c6a9e (diff)
downloadrneovim-4872e2da3cad407f0f45dbb5cc75d0c67743ad22.tar.gz
rneovim-4872e2da3cad407f0f45dbb5cc75d0c67743ad22.tar.bz2
rneovim-4872e2da3cad407f0f45dbb5cc75d0c67743ad22.zip
vim-patch:partial:8.0.1592: terminal windows in a session are not properly restored
Problem: Terminal windows in a session are not properly restored. Solution: Add "terminal" in 'sessionoptions'. When possible restore the command running in a terminal. https://github.com/vim/vim/commit/4d8bac8bf593ff087517ff79090c2d224325aae6 Tests only. Nvim has no equivalent to "norestore" yet. Co-authored-by: Bram Moolenaar <Bram@vim.org>
-rw-r--r--test/old/testdir/test_mksession.vim102
1 files changed, 102 insertions, 0 deletions
diff --git a/test/old/testdir/test_mksession.vim b/test/old/testdir/test_mksession.vim
index 369929e3a0..802211b2c2 100644
--- a/test/old/testdir/test_mksession.vim
+++ b/test/old/testdir/test_mksession.vim
@@ -353,6 +353,108 @@ func Test_mksession_blank_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')
+
func Test_mkview_open_folds()
enew!