mirror of
https://github.com/neovim/neovim.git
synced 2026-08-29 10:31:48 +00:00
fix(startup): server fails if $NVIM_APPNAME is relative dir #30310
Problem: If $NVIM_APPNAME is a relative dir path, Nvim fails to start its primary/default server, and `v:servername` is empty. Root cause isd34c64e342, but this wasn't noticed until96128a5076started reporting the error more loudly. Solution: - `server_address_new`: replace slashes "/" in the appname before using it as a servername. - `vim_mktempdir`: always prefer the system-wide top-level "nvim.user/" directory. That isn't intended to be specific to NVIM_APPNAME; rather, each *subdirectory* ("nvim.user/xxx") is owned by each Nvim instance. Nvim "apps" can be identified by the server socket(s) stored in those per-Nvim subdirs. fix #30256
This commit is contained in:
@@ -915,7 +915,7 @@ describe('stdpath()', function()
|
||||
assert_alive() -- Check for crash. #8393
|
||||
end)
|
||||
|
||||
it('supports $NVIM_APPNAME', function()
|
||||
it('$NVIM_APPNAME', function()
|
||||
local appname = 'NVIM_APPNAME_TEST' .. ('_'):rep(106)
|
||||
clear({ env = { NVIM_APPNAME = appname, NVIM_LOG_FILE = testlog } })
|
||||
eq(appname, fn.fnamemodify(fn.stdpath('config'), ':t'))
|
||||
@@ -957,6 +957,25 @@ describe('stdpath()', function()
|
||||
test_appname('a/b\\c', 0)
|
||||
end)
|
||||
|
||||
it('$NVIM_APPNAME relative path', function()
|
||||
local tmpdir = t.tmpname(false)
|
||||
t.mkdir(tmpdir)
|
||||
|
||||
clear({
|
||||
args_rm = { '--listen' },
|
||||
env = {
|
||||
NVIM_APPNAME = 'relative/appname',
|
||||
NVIM_LOG_FILE = testlog,
|
||||
TMPDIR = tmpdir,
|
||||
},
|
||||
})
|
||||
|
||||
t.matches(vim.pesc(tmpdir), fn.tempname():gsub('\\', '/'))
|
||||
t.assert_nolog('tempdir', testlog, 100)
|
||||
t.assert_nolog('TMPDIR', testlog, 100)
|
||||
t.matches([=[[/\\]relative%-appname.[^/\\]+]=], api.nvim_get_vvar('servername'))
|
||||
end)
|
||||
|
||||
describe('returns a String', function()
|
||||
describe('with "config"', function()
|
||||
it('knows XDG_CONFIG_HOME', function()
|
||||
|
||||
Reference in New Issue
Block a user