From 0a48f307b115d200c251a2d6c386b6c675747d37 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Tue, 23 Dec 2025 14:48:08 +0100 Subject: [PATCH 1/2] Add test expectation showing a problem with revert After the revert, the main view shows the diff of the wrong commit. --- pkg/integration/tests/commit/revert.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/integration/tests/commit/revert.go b/pkg/integration/tests/commit/revert.go index b295abf92..8e1bb125c 100644 --- a/pkg/integration/tests/commit/revert.go +++ b/pkg/integration/tests/commit/revert.go @@ -32,6 +32,12 @@ var Revert = NewIntegrationTest(NewIntegrationTestArgs{ Contains("Revert \"first commit\""), Contains("first commit").IsSelected(), ). + Tap(func() { + /* EXPECTED: + t.Views().Main().Content(Contains("+myfile content")) + ACTUAL: */ + t.Views().Main().Content(Contains("-myfile content")) + }). SelectPreviousItem() t.Views().Main().Content(Contains("-myfile content")) From a415d1b5293d73dfa1564a4f72e611c648a2d805 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Tue, 23 Dec 2025 14:45:42 +0100 Subject: [PATCH 2/2] Fix the main view display after reverting a commit We move the selection down by the number of commits that were reverted (to keep the same commits selected). However, this only happens after refreshing, which has rendered the main view with the wrong commit, so we need to render it again after moving the selection. There are many other callers of MoveSelection in LocalCommitsController, but all of them happen before the refresh. Revert is special because it needs to move the selection after refreshing, e.g. when reverting the only commit of a branch. --- pkg/gui/controllers/local_commits_controller.go | 2 +- pkg/integration/tests/commit/revert.go | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go index 3168b7ff3..5b76fd700 100644 --- a/pkg/gui/controllers/local_commits_controller.go +++ b/pkg/gui/controllers/local_commits_controller.go @@ -869,7 +869,7 @@ func (self *LocalCommitsController) revert(commits []*models.Commit, start, end return err } self.context().MoveSelection(len(commits)) - self.context().FocusLine() + self.context().HandleFocus(types.OnFocusOpts{}) if mustStash { if err := self.c.Git().Stash.Pop(0); err != nil { diff --git a/pkg/integration/tests/commit/revert.go b/pkg/integration/tests/commit/revert.go index 8e1bb125c..e9f3711f2 100644 --- a/pkg/integration/tests/commit/revert.go +++ b/pkg/integration/tests/commit/revert.go @@ -33,10 +33,7 @@ var Revert = NewIntegrationTest(NewIntegrationTestArgs{ Contains("first commit").IsSelected(), ). Tap(func() { - /* EXPECTED: t.Views().Main().Content(Contains("+myfile content")) - ACTUAL: */ - t.Views().Main().Content(Contains("-myfile content")) }). SelectPreviousItem()