aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-05-19 06:47:33 +0800
committerGitHub <noreply@github.com>2022-05-19 06:47:33 +0800
commit18fbdaeeab4bc1ed19bd3d7b3a0c0ded9cf79d4e (patch)
tree9455c239e8171e783d37e860a380e8780f7e3f70 /test
parent6f0baa0bb7a57ec4451047876321eb6f24130b10 (diff)
downloadrneovim-18fbdaeeab4bc1ed19bd3d7b3a0c0ded9cf79d4e.tar.gz
rneovim-18fbdaeeab4bc1ed19bd3d7b3a0c0ded9cf79d4e.tar.bz2
rneovim-18fbdaeeab4bc1ed19bd3d7b3a0c0ded9cf79d4e.zip
fix(termopen): avoid ambiguity in URI when CWD is root dir (#16988)
Diffstat (limited to 'test')
-rw-r--r--test/functional/ex_cmds/mksession_spec.lua42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/functional/ex_cmds/mksession_spec.lua b/test/functional/ex_cmds/mksession_spec.lua
index 97e41bbe83..cca6b45928 100644
--- a/test/functional/ex_cmds/mksession_spec.lua
+++ b/test/functional/ex_cmds/mksession_spec.lua
@@ -1,5 +1,6 @@
local lfs = require('lfs')
local helpers = require('test.functional.helpers')(after_each)
+local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
local command = helpers.command
@@ -119,4 +120,45 @@ describe(':mksession', function()
command('bd!')
sleep(100) -- Make sure the process exits.
end)
+
+ it('restores CWD for :terminal buffer at root directory #16988', function()
+ if helpers.iswin() then
+ pending('N/A for Windows')
+ return
+ end
+
+ local screen
+ local cwd_dir = funcs.fnamemodify('.', ':p:~'):gsub([[[\/]*$]], '')
+ local session_path = cwd_dir..'/'..session_file
+
+ screen = Screen.new(50, 6)
+ screen:attach({rgb=false})
+ local expected_screen = [[
+ ^/ |
+ |
+ [Process exited 0] |
+ |
+ |
+ |
+ ]]
+
+ command('cd /')
+ command('terminal echo $PWD')
+
+ -- Verify that the terminal's working directory is "/".
+ screen:expect(expected_screen)
+
+ command('cd '..cwd_dir)
+ command('mksession '..session_path)
+ command('qall!')
+
+ -- Create a new test instance of Nvim.
+ clear()
+ screen = Screen.new(50, 6)
+ screen:attach({rgb=false})
+ command('silent source '..session_path)
+
+ -- Verify that the terminal's working directory is "/".
+ screen:expect(expected_screen)
+ end)
end)