mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
tchdir: New tab should inherit CWD. (#5227)
When a new tabpage gets created it will copy the local working directory of the previous one, if there is any.
This commit is contained in:
parent
5d8d24f0c2
commit
626065d385
@ -2978,6 +2978,9 @@ int win_new_tabpage(int after, char_u *filename)
|
|||||||
xfree(newtp);
|
xfree(newtp);
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newtp->localdir = tp->localdir ? vim_strsave(tp->localdir) : NULL;
|
||||||
|
|
||||||
curtab = newtp;
|
curtab = newtp;
|
||||||
|
|
||||||
/* Create a new empty window. */
|
/* Create a new empty window. */
|
||||||
|
@ -140,6 +140,27 @@ for _, cmd in ipairs {'cd', 'chdir'} do
|
|||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
describe('Local directory gets inherited', function()
|
||||||
|
it('by tabs', function()
|
||||||
|
local globalDir = directories.start
|
||||||
|
|
||||||
|
-- Create a new tab and change directory
|
||||||
|
execute('tabnew')
|
||||||
|
execute('silent t' .. cmd .. ' ' .. directories.tab)
|
||||||
|
eq(globalDir .. '/' .. directories.tab, tcwd())
|
||||||
|
|
||||||
|
-- Create a new tab and verify it has inherited the directory
|
||||||
|
execute('tabnew')
|
||||||
|
eq(globalDir .. '/' .. directories.tab, tcwd())
|
||||||
|
|
||||||
|
-- Change tab and change back, verify that directories are correct
|
||||||
|
execute('tabnext')
|
||||||
|
eq(globalDir, tcwd())
|
||||||
|
execute('tabprevious')
|
||||||
|
eq(globalDir .. '/' .. directories.tab, tcwd())
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
it('works', function()
|
it('works', function()
|
||||||
local globalDir = directories.start
|
local globalDir = directories.start
|
||||||
-- Create a new tab first and verify that is has the same working dir
|
-- Create a new tab first and verify that is has the same working dir
|
||||||
|
Loading…
Reference in New Issue
Block a user