From d9839667a715ae828a762fa7d81a7deae81f9c91 Mon Sep 17 00:00:00 2001 From: David Yonge-Mallo Date: Fri, 8 May 2026 06:55:58 +0200 Subject: [PATCH] fix(file_history): position cursor on active item when panel starts open --- .../views/file_history/file_history_panel.lua | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lua/diffview/scene/views/file_history/file_history_panel.lua b/lua/diffview/scene/views/file_history/file_history_panel.lua index 2f8284f8..16663a8c 100644 --- a/lua/diffview/scene/views/file_history/file_history_panel.lua +++ b/lua/diffview/scene/views/file_history/file_history_panel.lua @@ -270,11 +270,16 @@ FileHistoryPanel.update_entries = async.wrap(function(self, callback) if self.shutdown:check() then return end - if not self:cur_file() then - self:update_components() - self.parent:next_item() - else - self:sync() + + local bootstrap_file + if not self:cur_file() and self:num_items() > 0 then + bootstrap_file = self:next_file() + end + + self:sync() + + if bootstrap_file then + self.parent:set_file(bootstrap_file) end vim.cmd("redraw")