diff options
author | Chris LaRose <cjlarose@gmail.com> | 2020-01-26 00:24:42 -0800 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2020-01-26 00:24:42 -0800 |
commit | c6ff23d7a0d5ccf0d8995e3204c18df55d28fc7f (patch) | |
tree | 0614f7241a3fccd0c708d541bdc9e5ab4e15afca /test/functional/ex_cmds/mksession_spec.lua | |
parent | 451af7f08779ba39d3ebef4b2295ba702cc4f3d7 (diff) | |
download | rneovim-c6ff23d7a0d5ccf0d8995e3204c18df55d28fc7f.tar.gz rneovim-c6ff23d7a0d5ccf0d8995e3204c18df55d28fc7f.tar.bz2 rneovim-c6ff23d7a0d5ccf0d8995e3204c18df55d28fc7f.zip |
terminal: absolute CWD in term:// URI #11289
This makes it possible to restore the working directory of :terminal
buffers when reading those buffers from a session file.
Fixes #11288
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
Diffstat (limited to 'test/functional/ex_cmds/mksession_spec.lua')
-rw-r--r-- | test/functional/ex_cmds/mksession_spec.lua | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/test/functional/ex_cmds/mksession_spec.lua b/test/functional/ex_cmds/mksession_spec.lua index 0f7860740e..855f8105aa 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' @@ -48,7 +50,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 +72,23 @@ 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([[[\/]*$]], '') + local session_path = cwd_dir..get_pathsep()..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..get_pathsep()..tab_dir + matches('^term://'..pesc(expected_cwd)..'//%d+:', funcs.expand('%')) + command('qall!') + end) end) |