fix(termopen): avoid ambiguity in URI when CWD is root dir (#16988)

This commit is contained in:
zeertzjq
2022-05-19 06:47:33 +08:00
committed by GitHub
parent 6f0baa0bb7
commit 18fbdaeeab
2 changed files with 49 additions and 1 deletions

View File

@@ -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)