mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-15 01:34:26 +02:00
Adjust selection after cherry-picking commits
Keep the same commit selected, by moving the selection down by the number of cherry-picked commits. We also do this when reverting commits, and it is possible now that we use a sync waiting status. We also need to turn the refresh that happens as part of CheckMergeOrRebase into a sync one, so that the commits list is up to date and the new selection isn't clamped.
This commit is contained in:
@ -87,12 +87,23 @@ func (self *CherryPickHelper) Paste() error {
|
||||
}
|
||||
}
|
||||
|
||||
result := self.c.Git().Rebase.CherryPickCommits(self.getData().CherryPickedCommits)
|
||||
err := self.rebaseHelper.CheckMergeOrRebase(result)
|
||||
cherryPickedCommits := self.getData().CherryPickedCommits
|
||||
result := self.c.Git().Rebase.CherryPickCommits(cherryPickedCommits)
|
||||
err := self.rebaseHelper.CheckMergeOrRebaseWithRefreshOptions(result, types.RefreshOptions{Mode: types.SYNC})
|
||||
if err != nil {
|
||||
return result
|
||||
}
|
||||
|
||||
// Move the selection down by the number of commits we just
|
||||
// cherry-picked, to keep the same commit selected as before.
|
||||
// Don't do this if a rebase todo is selected, because in this
|
||||
// case we are in a rebase and the cherry-picked commits end up
|
||||
// below the selection.
|
||||
if commit := self.c.Contexts().LocalCommits.GetSelected(); commit != nil && !commit.IsTODO() {
|
||||
self.c.Contexts().LocalCommits.MoveSelection(len(cherryPickedCommits))
|
||||
self.c.Contexts().LocalCommits.FocusLine()
|
||||
}
|
||||
|
||||
// If we're in the cherry-picking state at this point, it must
|
||||
// be because there were conflicts. Don't clear the copied
|
||||
// commits in this case, since we might want to abort and try
|
||||
|
@ -73,9 +73,9 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
t.Views().Information().Content(DoesNotContain("commits copied"))
|
||||
}).
|
||||
Lines(
|
||||
Contains("four").IsSelected(),
|
||||
Contains("four"),
|
||||
Contains("three"),
|
||||
Contains("two"),
|
||||
Contains("two").IsSelected(),
|
||||
Contains("one"),
|
||||
Contains("base"),
|
||||
)
|
||||
@ -102,9 +102,9 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
t.Views().Information().Content(DoesNotContain("commits copied"))
|
||||
}).
|
||||
Lines(
|
||||
Contains("four").IsSelected(),
|
||||
Contains("four"),
|
||||
Contains("three"),
|
||||
Contains("base"),
|
||||
Contains("base").IsSelected(),
|
||||
)
|
||||
},
|
||||
})
|
||||
|
@ -79,8 +79,8 @@ var CherryPickDuringRebase = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains("--- Pending rebase todos ---"),
|
||||
Contains("pick CI two"),
|
||||
Contains("--- Commits ---"),
|
||||
Contains(" CI three").IsSelected(),
|
||||
Contains(" CI one"),
|
||||
Contains(" CI three"),
|
||||
Contains(" CI one").IsSelected(),
|
||||
Contains(" CI base"),
|
||||
).
|
||||
Tap(func() {
|
||||
@ -88,8 +88,8 @@ var CherryPickDuringRebase = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
}).
|
||||
Lines(
|
||||
Contains("CI two"),
|
||||
Contains("CI three").IsSelected(),
|
||||
Contains("CI one"),
|
||||
Contains("CI three"),
|
||||
Contains("CI one").IsSelected(),
|
||||
Contains("CI base"),
|
||||
)
|
||||
},
|
||||
|
@ -63,9 +63,10 @@ var CherryPickMerge = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
t.Views().Information().Content(DoesNotContain("commit copied"))
|
||||
}).
|
||||
Lines(
|
||||
Contains("Merge branch 'second-branch'").IsSelected(),
|
||||
Contains("base"),
|
||||
)
|
||||
Contains("Merge branch 'second-branch'"),
|
||||
Contains("base").IsSelected(),
|
||||
).
|
||||
SelectPreviousItem()
|
||||
|
||||
t.Views().Main().ContainsLines(
|
||||
Contains("Merge branch 'second-branch'"),
|
||||
|
@ -70,9 +70,9 @@ var CherryPickRange = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
t.Views().Information().Content(DoesNotContain("commits copied"))
|
||||
}).
|
||||
Lines(
|
||||
Contains("four").IsSelected(),
|
||||
Contains("four"),
|
||||
Contains("three"),
|
||||
Contains("two"),
|
||||
Contains("two").IsSelected(),
|
||||
Contains("one"),
|
||||
Contains("base"),
|
||||
)
|
||||
|
@ -43,8 +43,8 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Confirm()
|
||||
}).
|
||||
Lines(
|
||||
Contains("three").IsSelected(),
|
||||
Contains("one"),
|
||||
Contains("three"),
|
||||
Contains("one").IsSelected(),
|
||||
)
|
||||
},
|
||||
})
|
||||
|
Reference in New Issue
Block a user