diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2024-05-20 20:58:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-20 20:58:31 +0200 |
commit | 6343fb57d605a488f4d3ff6cd1f13341307b6159 (patch) | |
tree | f458395409aefe963766a9b868bb709b7e0bf411 | |
parent | a4e9181a6b2feb8c9f7f02ea409e22857bed9464 (diff) | |
parent | 5af0ea85fcfdd02d7ac72bc11b68e432a70bafdf (diff) |
Focus on local commits view after moving code into new commit (#3577)
- **PR Description**
This PR forces lazygit to focus to the `Commits` view after moving a
custom (partial) patch in a new commit.
This closes #3200.
-rw-r--r-- | pkg/gui/controllers/custom_patch_options_menu_action.go | 5 | ||||
-rw-r--r-- | pkg/integration/tests/patch_building/move_to_new_commit_partial_hunk.go | 10 |
2 files changed, 14 insertions, 1 deletions
diff --git a/pkg/gui/controllers/custom_patch_options_menu_action.go b/pkg/gui/controllers/custom_patch_options_menu_action.go index 2d57f0ac0..f5099ae2e 100644 --- a/pkg/gui/controllers/custom_patch_options_menu_action.go +++ b/pkg/gui/controllers/custom_patch_options_menu_action.go @@ -217,7 +217,10 @@ func (self *CustomPatchOptionsMenuAction) handlePullPatchIntoNewCommit() error { _ = self.c.Helpers().Commits.PopCommitMessageContexts() self.c.LogAction(self.c.Tr.Actions.MovePatchIntoNewCommit) err := self.c.Git().Patch.PullPatchIntoNewCommit(self.c.Model().Commits, commitIndex, summary, description) - return self.c.Helpers().MergeAndRebase.CheckMergeOrRebase(err) + if err := self.c.Helpers().MergeAndRebase.CheckMergeOrRebase(err); err != nil { + return err + } + return self.c.PushContext(self.c.Contexts().LocalCommits) }) }, }, diff --git a/pkg/integration/tests/patch_building/move_to_new_commit_partial_hunk.go b/pkg/integration/tests/patch_building/move_to_new_commit_partial_hunk.go index dd0b4c3f2..62dfb1dec 100644 --- a/pkg/integration/tests/patch_building/move_to_new_commit_partial_hunk.go +++ b/pkg/integration/tests/patch_building/move_to_new_commit_partial_hunk.go @@ -51,6 +51,16 @@ var MoveToNewCommitPartialHunk = NewIntegrationTest(NewIntegrationTestArgs{ InitialText(Equals("")). Type("new commit").Confirm() + t.Views().Commits(). + IsFocused(). + Lines( + Contains("third commit"), + Contains("new commit").IsSelected(), + Contains("commit to move from"), + Contains("first commit"), + ). + PressEnter() + t.Views().CommitFiles(). IsFocused(). Lines( |