Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lua/codediff/ui/view/side_by_side/update.lua
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ function M.update(tabpage, session_config, auto_scroll_to_first_hunk)
modified = modified_is_virtual and modified_info.needs_edit,
}

local render_everything = function()
local render_everything
render_everything = function()
if not current() then
return
end
Expand All @@ -206,6 +207,15 @@ function M.update(tabpage, session_config, auto_scroll_to_first_hunk)
return
end

-- Guard: a reentrant vim.wait() (e.g. from a BufEnter autocmd fired by
-- open_real_file) can run this before reload_side has assigned bufnr.
if not original_info.bufnr or not modified_info.bufnr then
-- A timer, not vim.schedule: vim.wait() drains scheduled callbacks, so
-- re-queueing here would spin inside the very wait that blocks us.
vim.defer_fn(render_everything, 10)
return
end

-- Guard: Check if buffers are still valid
if not vim.api.nvim_buf_is_valid(original_info.bufnr) or not vim.api.nvim_buf_is_valid(modified_info.bufnr) then
return
Expand Down