summaryrefslogtreecommitdiffstatshomepage
path: root/runtime/lua/vim/_system.lua
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2025-07-02 12:08:48 +0100
committerLewis Russell <me@lewisr.dev>2025-07-02 17:01:29 +0100
commit4eebc46930008d7cf47491121556ee201e1f4860 (patch)
tree03cf369b044a12b4ac0a87af9b2be12c7dc6232b /runtime/lua/vim/_system.lua
parente91224bfaa043bb85cdfa6394f417e400522ff53 (diff)
fix(vim.system): env=nil passes env=nil to uv.spawn
731e616a79 made it so passing `{env = nil, clear_env = true }` would pass `{env = {}}` to `vim.uv.spawn`. However this is not what `clear_env` is (arguably) supposed to do. If `env=nil` then that implies the uses wants `vim.uv.spawn()` to use the default environment. Adding `clear_env = true` simply prevents `NVIM` (the base environment) from being added. Fixes #34730
Diffstat (limited to 'runtime/lua/vim/_system.lua')
-rw-r--r--runtime/lua/vim/_system.lua9
1 files changed, 7 insertions, 2 deletions
diff --git a/runtime/lua/vim/_system.lua b/runtime/lua/vim/_system.lua
index 38e348bc03..ced341fe28 100644
--- a/runtime/lua/vim/_system.lua
+++ b/runtime/lua/vim/_system.lua
@@ -208,13 +208,18 @@ end
--- @param clear_env? boolean
--- @return string[]?
local function setup_env(env, clear_env)
+ if not env and clear_env then
+ return
+ end
+
+ env = env or {}
if not clear_env then
--- @type table<string,string|number>
- env = vim.tbl_extend('force', base_env(), env or {})
+ env = vim.tbl_extend('force', base_env(), env)
end
local renv = {} --- @type string[]
- for k, v in pairs(env or {}) do
+ for k, v in pairs(env) do
renv[#renv + 1] = string.format('%s=%s', k, tostring(v))
end