mirror of
https://github.com/neovim/neovim.git
synced 2026-08-17 21:04:47 -05:00
fix(restart): preserve global cwd on :restart #41304
Problem: On :restart, the new Nvim may "inherit" a local dir as its global CWD. Solution: Inherit the global CWD explicitly.
This commit is contained in:
+1
-1
@@ -5005,7 +5005,7 @@ static void ex_restart(exarg_T *eap)
|
||||
Channel *channel = channel_job_start(argv, exepath,
|
||||
CALLBACK_READER_INIT, on_err, CALLBACK_NONE,
|
||||
false, true, true, detach, kChannelStdinPipe,
|
||||
NULL, 0, 0, env, &exit_status);
|
||||
globaldir, 0, 0, env, &exit_status);
|
||||
if (!channel) {
|
||||
emsg("cannot create a channel job");
|
||||
goto fail_1;
|
||||
|
||||
@@ -452,11 +452,16 @@ it(':restart! works in headless server (no UI)', function()
|
||||
|
||||
local nvim0 = clear()
|
||||
local server_pipe = n.new_pipename()
|
||||
local dir = vim.fs.normalize(t.tmpname(false))
|
||||
local subdir = dir .. '/subdir'
|
||||
mkdir(dir)
|
||||
mkdir(subdir)
|
||||
|
||||
finally(function()
|
||||
n.expect_exit(n.command, 'qall!')
|
||||
nvim0:close()
|
||||
n.set_session(nil)
|
||||
rmdir(dir)
|
||||
end)
|
||||
|
||||
fn.jobstart({
|
||||
@@ -473,11 +478,17 @@ it(':restart! works in headless server (no UI)', function()
|
||||
end)
|
||||
n.set_session(n.connect(server_pipe))
|
||||
|
||||
api.nvim_set_current_dir(dir)
|
||||
n.command('bcd ' .. fn.fnameescape(subdir))
|
||||
eq(subdir, fn.getcwd())
|
||||
eq(dir, fn.getcwd(-1, -1, -1))
|
||||
|
||||
n.expect_exit(n.command, 'restart!')
|
||||
n.set_session(n.connect(server_pipe))
|
||||
eq(1, api.nvim_get_vvar('vim_did_enter'))
|
||||
eq('restart!', api.nvim_get_vvar('startreason'))
|
||||
eq('restart!', n.eval('g:early_startreason'))
|
||||
eq(dir, fn.getcwd())
|
||||
|
||||
-- TODO: [command] is currently not executed without UI
|
||||
-- n.expect_exit(n.command, 'restart! lua _G.new_server = 1')
|
||||
|
||||
Reference in New Issue
Block a user