Skip to content

Commit dc795b5

Browse files
committed
Remove unnecessary refresh
CheckMergeOrRebase calls Refresh already. However, it does an async refresh by default, so we must turn this into a sync refresh so that moving the selection down by one works even for the very first commit in history. Also, we must add an explicit call to FocusLine so that the view selection is in sync with the model selection; previously this was taken care of by the PostRefreshUpdate call that happens as part of a refresh.
1 parent 0fc107c commit dc795b5

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

pkg/gui/controllers/local_commits_controller.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -874,13 +874,11 @@ func (self *LocalCommitsController) revert(commits []*models.Commit, start, end
874874
self.c.LogAction(self.c.Tr.Actions.RevertCommit)
875875
return self.c.WithWaitingStatusSync(self.c.Tr.RevertingStatus, func() error {
876876
result := self.c.Git().Commit.Revert(hashes, isMerge)
877-
if err := self.c.Helpers().MergeAndRebase.CheckMergeOrRebase(result); err != nil {
877+
if err := self.c.Helpers().MergeAndRebase.CheckMergeOrRebaseWithRefreshOptions(result, types.RefreshOptions{Mode: types.SYNC}); err != nil {
878878
return err
879879
}
880880
self.context().MoveSelection(len(commits))
881-
self.c.Refresh(types.RefreshOptions{
882-
Mode: types.SYNC, Scope: []types.RefreshableView{types.COMMITS, types.BRANCHES},
883-
})
881+
self.context().FocusLine()
884882
return nil
885883
})
886884
},

pkg/integration/tests/commit/revert.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ var Revert = NewIntegrationTest(NewIntegrationTestArgs{
2929
Confirm()
3030
}).
3131
Lines(
32-
Contains("Revert \"first commit\"").IsSelected(),
33-
Contains("first commit"),
34-
)
32+
Contains("Revert \"first commit\""),
33+
Contains("first commit").IsSelected(),
34+
).
35+
SelectPreviousItem()
3536

3637
t.Views().Main().Content(Contains("-myfile content"))
3738
t.FileSystem().PathNotPresent("myfile")

0 commit comments

Comments
 (0)