From 8c1cc685312e3a18e5c1d911362025cd7cf6539b Mon Sep 17 00:00:00 2001 From: David Milum Date: Sat, 11 Jul 2026 11:49:29 -0400 Subject: [PATCH] CommitView: '}' mapping goes to first hunk --- lua/neogit/buffers/commit_view/init.lua | 9 +++++++++ lua/neogit/lib/ui/init.lua | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lua/neogit/buffers/commit_view/init.lua b/lua/neogit/buffers/commit_view/init.lua index 1960b06dd..17a3091c0 100644 --- a/lua/neogit/buffers/commit_view/init.lua +++ b/lua/neogit/buffers/commit_view/init.lua @@ -369,6 +369,15 @@ function M:open(kind) end end vim.cmd("normal! zt") + else + -- Possibly in the header, scan down to the first hunk + local firstHunk = self.buffer.ui:find_component(function(c) + return c.options.tag == "Hunk" + end) + if firstHunk ~= nil then + local first, _ = firstHunk:row_range_abs() + self.buffer:move_cursor(first) + end end end, [popups.mapping_for("BisectPopup")] = popups.open("bisect", function(p) diff --git a/lua/neogit/lib/ui/init.lua b/lua/neogit/lib/ui/init.lua index 85d940823..48d187c44 100644 --- a/lua/neogit/lib/ui/init.lua +++ b/lua/neogit/lib/ui/init.lua @@ -66,7 +66,7 @@ end ---@param f fun(c: UiComponent): boolean ---@param options FindOptions|nil function Ui:find_component(f, options) - return Ui._find_component(self.layout, f, options or {}) + return Ui._find_component(self.layout.children, f, options or {}) end ---@param fn? fun(c: Component): boolean