From 2abe4848f32d532d818211e47c6210a62785193d Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 9 Oct 2026 08:50:53 +0200 Subject: [PATCH] Scroll back to the left edge when jumping to another file of a diff Going to the next or previous file of a diff, or picking one from the jump-to-file menu or the diffstat, brings that file to the top of the view. The user goes there to read the file from its start, so scroll the view back to the left edge as well. Jumps between the hunks of a diff keep the horizontal scroll position, as moving the selection does. Nothing scrolls the main view horizontally yet, so this changes nothing on its own. It prepares for scrolling the focused main view sideways with H and L. Co-Authored-By: Claude Opus 5.5 (1M context) --- pkg/gui/controllers/helpers/diff_line_selection.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/gui/controllers/helpers/diff_line_selection.go b/pkg/gui/controllers/helpers/diff_line_selection.go index e80147a1e..4d6b26b51 100644 --- a/pkg/gui/controllers/helpers/diff_line_selection.go +++ b/pkg/gui/controllers/helpers/diff_line_selection.go @@ -75,6 +75,10 @@ func (self *DiffLineHelper) EstablishSelection(mainContext *context.MainContext, // the first change block at or below the target, which a large context size can put // further down than a screenful; the selection is then scrolled into view as any other // jump's is, and the alignment gives way to that. +// +// A jump that aligns its target to the top also scrolls the view back to the left +// edge, whether or not the target is on screen already. Such a jump goes to a file, and +// the user goes there to read the file from its start. func (self *DiffLineHelper) PlaceNavigationTarget( pane types.DiffPaneContext, target int, alignTop bool, ) { @@ -84,6 +88,7 @@ func (self *DiffLineHelper) PlaceNavigationTarget( return } if alignTop { + view.SetOriginX(0) self.scrollTargetToTop(pane, target) } // Jumping to another block or file moves the cursor without shift held, so a