refactor(path): more slash normalization #39426

Problem:
1. `vim_getenv` is followed by `TO_SLASH` when getting
path-related variables.
2. cmd exits when launched with forward slash.

Solution:
1. try calling `TO_SLASH` in `vim_getenv`.
2. pass fullpath via `lpApplicationName`, only include `cmd.exe`
in cmdline.

Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
This commit is contained in:
tao
2026-04-30 04:33:22 +08:00
committed by GitHub
parent 7cd0e40039
commit 040bdf0bc5
4 changed files with 41 additions and 11 deletions

View File

@@ -35,7 +35,7 @@ describe('vim.fn.environ()', function()
local env = vim.fn.environ()
assert(vim.tbl_count(env) > 10, 'environ() should have some env vars!')
for k, v in pairs(env) do
if v ~= '' and vim.fn.getenv(k) ~= v then
if v ~= '' and vim.fn.getenv(k) ~= v and vim.fn.getenv(k) ~= v:gsub('\\', '/') then
error(('environ()[%q] = %q, but vim.fn.getenv(%q) = %q'):format(k, v, k, vim.fn.getenv(k)))
end
end