diff options
-rw-r--r-- | src/nvim/ex_docmd.c | 1 | ||||
-rw-r--r-- | test/functional/ex_cmds/mksession_spec.lua | 23 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 3467bc8b92..0ea383dbb6 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -9130,6 +9130,7 @@ makeopens( || put_eol(fd) == FAIL) { return FAIL; } + did_lcd = true; } /* Don't continue in another tab page when doing only the current one diff --git a/test/functional/ex_cmds/mksession_spec.lua b/test/functional/ex_cmds/mksession_spec.lua index a5b327095e..0f7860740e 100644 --- a/test/functional/ex_cmds/mksession_spec.lua +++ b/test/functional/ex_cmds/mksession_spec.lua @@ -47,4 +47,27 @@ describe(':mksession', function() command('tabnext 2') eq(cwd_dir .. get_pathsep() .. tab_dir, funcs.getcwd()) end) + + it('restores buffers when using tab-local working directories', function() + local tmpfile_base = file_prefix .. '-tmpfile' + local cwd_dir = funcs.getcwd() + local session_path = cwd_dir .. get_pathsep() .. session_file + + command('edit ' .. tmpfile_base .. '1') + command('tcd ' .. tab_dir) + command('tabnew') + command('edit ' .. cwd_dir .. get_pathsep() .. tmpfile_base .. '2') + command('tabfirst') + command('mksession ' .. session_path) + + -- Create a new test instance of Nvim. + clear() + + -- Use :silent to avoid press-enter prompt due to long path + command('silent source ' .. session_path) + command('tabnext 1') + eq(cwd_dir .. get_pathsep() .. tmpfile_base .. '1', funcs.expand('%:p')) + command('tabnext 2') + eq(cwd_dir .. get_pathsep() .. tmpfile_base .. '2', funcs.expand('%:p')) + end) end) |