From 181e735c3bfc83068baaffc90287c54b8fac1fe9 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Fri, 20 Feb 2026 20:51:39 -0500 Subject: [PATCH] fix: move opts cast after second tbl_deep_extend in render_buffer_async Problem: the ---@cast opts -nil was placed after the first opts guard but LuaLS loses narrowing at the second tbl_deep_extend on line 928, causing a persistent need-check-nil warning at opts.refetch. Solution: remove the redundant first opts = opts or {} guard (the tbl_deep_extend already handles nil) and place the cast after the second tbl_deep_extend where opts is actually used. --- lua/oil/view.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lua/oil/view.lua b/lua/oil/view.lua index 24a42f7..bc21dfb 100644 --- a/lua/oil/view.lua +++ b/lua/oil/view.lua @@ -911,8 +911,6 @@ local pending_renders = {} --- refetch nil|boolean Defaults to true ---@param caller_callback nil|fun(err: nil|string) M.render_buffer_async = function(bufnr, opts, caller_callback) - opts = opts or {} - ---@cast opts -nil local function callback(err) if not err then vim.api.nvim_exec_autocmds( @@ -928,6 +926,7 @@ M.render_buffer_async = function(bufnr, opts, caller_callback) opts = vim.tbl_deep_extend("keep", opts or {}, { refetch = true, }) + ---@cast opts -nil if bufnr == 0 then bufnr = vim.api.nvim_get_current_buf() end