From 94144d46787fc396dd9e830f2cde5a09f2b4307d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 11 Jan 2026 20:04:32 +0800 Subject: fix(lua): vim._with() doesn't save boolean options properly (#37354) Problem: vim._with() doesn't save boolean options with false values properly. Solution: Use vim.F.if_nil(). --- runtime/lua/vim/_core/shared.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'runtime/lua/vim') diff --git a/runtime/lua/vim/_core/shared.lua b/runtime/lua/vim/_core/shared.lua index 8dfca25fb9..1d1b64cb99 100644 --- a/runtime/lua/vim/_core/shared.lua +++ b/runtime/lua/vim/_core/shared.lua @@ -1473,13 +1473,13 @@ local get_context_state = function(context) -- Do not override already set state and fall back to `vim.NIL` for -- state `nil` values (which still needs restoring later) - res[sc][name] = res[sc][name] or vim[sc][name] or vim.NIL + res[sc][name] = vim.F.if_nil(res[sc][name], vim[sc][name], vim.NIL) -- Always track global option value to properly restore later. -- This matters for at least `o` and `wo` (which might set either/both -- local and global option values). - if sc ~= 'env' then - res.go[name] = res.go[name] or vim.go[name] + if sc ~= 'env' and res.go[name] == nil then + res.go[name] = vim.go[name] end end end -- cgit