diff options
Diffstat (limited to 'test/functional/ex_cmds/mksession_spec.lua')
-rw-r--r-- | test/functional/ex_cmds/mksession_spec.lua | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/test/functional/ex_cmds/mksession_spec.lua b/test/functional/ex_cmds/mksession_spec.lua index 0f7860740e..949724bb53 100644 --- a/test/functional/ex_cmds/mksession_spec.lua +++ b/test/functional/ex_cmds/mksession_spec.lua @@ -6,6 +6,8 @@ local command = helpers.command local get_pathsep = helpers.get_pathsep local eq = helpers.eq local funcs = helpers.funcs +local matches = helpers.matches +local pesc = helpers.pesc local rmdir = helpers.rmdir local file_prefix = 'Xtest-functional-ex_cmds-mksession_spec' @@ -24,6 +26,27 @@ describe(':mksession', function() rmdir(tab_dir) end) + it('restores same :terminal buf in splits', function() + -- If the same :terminal is displayed in multiple windows, :mksession + -- should restore it as such. + + -- Create two windows showing the same :terminal buffer. + command('terminal') + command('split') + command('terminal') + command('split') + command('mksession '..session_file) + + -- Create a new test instance of Nvim. + command('qall!') + clear() + -- Restore session. + command('source '..session_file) + + eq({3,3,2}, + {funcs.winbufnr(1), funcs.winbufnr(2), funcs.winbufnr(3)}) + end) + it('restores tab-local working directories', function() local tmpfile_base = file_prefix .. '-tmpfile' local cwd_dir = funcs.getcwd() @@ -48,7 +71,7 @@ describe(':mksession', function() eq(cwd_dir .. get_pathsep() .. tab_dir, funcs.getcwd()) end) - it('restores buffers when using tab-local working directories', function() + it('restores buffers with tab-local CWD', function() local tmpfile_base = file_prefix .. '-tmpfile' local cwd_dir = funcs.getcwd() local session_path = cwd_dir .. get_pathsep() .. session_file @@ -70,4 +93,24 @@ describe(':mksession', function() command('tabnext 2') eq(cwd_dir .. get_pathsep() .. tmpfile_base .. '2', funcs.expand('%:p')) end) + + it('restores CWD for :terminal buffers #11288', function() + local cwd_dir = funcs.fnamemodify('.', ':p:~'):gsub([[[\/]*$]], '') + cwd_dir = cwd_dir:gsub([[\]], '/') -- :mksession always uses unix slashes. + local session_path = cwd_dir..'/'..session_file + + command('cd '..tab_dir) + command('terminal echo $PWD') + command('cd '..cwd_dir) + command('mksession '..session_path) + command('qall!') + + -- Create a new test instance of Nvim. + clear() + command('silent source '..session_path) + + local expected_cwd = cwd_dir..'/'..tab_dir + matches('^term://'..pesc(expected_cwd)..'//%d+:', funcs.expand('%')) + command('qall!') + end) end) |