Skip to content

Commit f21c169

Browse files
zeertzjqgithub-actions[bot]
authored andcommitted
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(). (cherry picked from commit 94144d4)
1 parent 2a3cd8d commit f21c169

File tree

4 files changed

+117
-38
lines changed

4 files changed

+117
-38
lines changed

runtime/lua/vim/shared.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,13 +1277,13 @@ local get_context_state = function(context)
12771277

12781278
-- Do not override already set state and fall back to `vim.NIL` for
12791279
-- state `nil` values (which still needs restoring later)
1280-
res[sc][name] = res[sc][name] or vim[sc][name] or vim.NIL
1280+
res[sc][name] = vim.F.if_nil(res[sc][name], vim[sc][name], vim.NIL)
12811281

12821282
-- Always track global option value to properly restore later.
12831283
-- This matters for at least `o` and `wo` (which might set either/both
12841284
-- local and global option values).
1285-
if sc ~= 'env' then
1286-
res.go[name] = res.go[name] or vim.go[name]
1285+
if sc ~= 'env' and res.go[name] == nil then
1286+
res.go[name] = vim.go[name]
12871287
end
12881288
end
12891289
end

src/nvim/msgpack_rpc/channel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ static void chan_close_on_err(Channel *channel, char *msg, int loglevel)
529529
for (size_t i = 0; i < kv_size(channel->rpc.call_stack); i++) {
530530
ChannelCallFrame *frame = kv_A(channel->rpc.call_stack, i);
531531
if (frame->returned) {
532-
continue; // Don't overwrite an already received result.
532+
continue; // Don't overwrite an already received result. #24214
533533
}
534534
frame->returned = true;
535535
frame->errored = true;

test/functional/api/server_requests_spec.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ describe('server -> client', function()
396396
eq({}, api.nvim_get_chan_info(id)) -- Channel is closed.
397397
end)
398398

399-
it('response works with channel closed just after response', function()
399+
it('response works with channel closed just after response #24214', function()
400400
local id = start_server_and_client()
401401
eq(
402402
'RESPONSE',

0 commit comments

Comments
 (0)