mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-11-02 08:59:57 -06:00
Keep the horizontal scroll position when a diff is rendered again
Two places that position the main view after a re-render of the same diff call SetOrigin(0, y), although they only mean to move the view vertically. One is the restore after a change of the context size, of whitespace handling or of the diff renderer. The other is the clamp for content that ends above the scroll position, for example after staging a large part of the diff. Use SetOriginY in both, so that they keep the horizontal scroll position. 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) <noreply@anthropic.com>
This commit is contained in:
1 parent
abc16e904c
commit
4f678b7d0d
2 files changed
+2
-2
No files matched your search
@@ -81,7 +81,7 @@ func (self *DiffLineHelper) PreserveDiffPositionOnRerender(view *gocui.View) {
|
||||
// Put the line back on the screen row it was on, clamped into the view for
|
||||
// the fallback lines, which can come from off screen.
|
||||
row := lo.Clamp(anchor.row, 0, max(0, view.InnerHeight()-1))
|
||||
view.SetOrigin(0, max(0, viewLine-row))
|
||||
view.SetOriginY(max(0, viewLine-row))
|
||||
if showSelection {
|
||||
// Put the far end back before the cursor, so that the selection covers
|
||||
// the same lines again; a selection whose far end didn't survive the
|
||||
|
||||
Reference in new issue
Block a user