Skip to content

Commit 6fb7942

Browse files
authored
Fix wrong main view content after pressing e in a stack of branches (#4450)
- **PR Description** When pressing `e` (or `i`) in a stack of branches, we take care of maintaining the selected commit (as of #2954 for `e`, and #3247 for `i`), to account for the selection index changing because of added update-ref todos. This is great, however we missed that the main view diff now shows the wrong commit, which is very confusing. I'm surprised that this hasn't been noticed yet. - **Please check if the PR fulfills these requirements** * [x] Cheatsheets are up-to-date (run `go generate ./...`) * [x] Code has been formatted (see [here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting)) * [x] Tests have been added/updated (see [here](https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md) for the integration test guide) * [ ] Text is internationalised (see [here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation)) * [ ] If a new UserConfig entry was added, make sure it can be hot-reloaded (see [here](https://github.com/jesseduffield/lazygit/blob/master/docs/dev/Codebase_Guide.md#using-userconfig)) * [ ] Docs have been updated if necessary * [x] You've read through your own file changes for silly mistakes etc
2 parents 14187c9 + 59af407 commit 6fb7942

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

pkg/gui/controllers/local_commits_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ func (self *LocalCommitsController) restoreSelectionRangeAndMode(selectionRangeA
608608
})
609609
if ok1 && ok2 {
610610
self.context().SetSelectionRangeAndMode(newSelectedIdx, newRangeStartIdx, selectionRangeAndMode.mode)
611+
self.context().HandleFocus(types.OnFocusOpts{})
611612
}
612613
}
613614

pkg/integration/tests/interactive_rebase/drop_todo_commit_with_update_ref.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ var DropTodoCommitWithUpdateRef = NewIntegrationTest(NewIntegrationTestArgs{
4848
Contains("<-- YOU ARE HERE --- commit 02").IsSelected(),
4949
Contains("CI commit 01"),
5050
).
51+
Tap(func() {
52+
t.Views().Main().Content(Contains("commit 02"))
53+
}).
5154
NavigateToLine(Contains("commit 06")).
5255
Press(keys.Universal.Remove)
5356

0 commit comments

Comments
 (0)