mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-17 01:42:45 +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)
|
cherryPickedCommits := self.getData().CherryPickedCommits
|
||||||
err := self.rebaseHelper.CheckMergeOrRebase(result)
|
result := self.c.Git().Rebase.CherryPickCommits(cherryPickedCommits)
|
||||||
|
err := self.rebaseHelper.CheckMergeOrRebaseWithRefreshOptions(result, types.RefreshOptions{Mode: types.SYNC})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result
|
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
|
// If we're in the cherry-picking state at this point, it must
|
||||||
// be because there were conflicts. Don't clear the copied
|
// be because there were conflicts. Don't clear the copied
|
||||||
// commits in this case, since we might want to abort and try
|
// 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"))
|
t.Views().Information().Content(DoesNotContain("commits copied"))
|
||||||
}).
|
}).
|
||||||
Lines(
|
Lines(
|
||||||
Contains("four").IsSelected(),
|
Contains("four"),
|
||||||
Contains("three"),
|
Contains("three"),
|
||||||
Contains("two"),
|
Contains("two").IsSelected(),
|
||||||
Contains("one"),
|
Contains("one"),
|
||||||
Contains("base"),
|
Contains("base"),
|
||||||
)
|
)
|
||||||
@ -102,9 +102,9 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
t.Views().Information().Content(DoesNotContain("commits copied"))
|
t.Views().Information().Content(DoesNotContain("commits copied"))
|
||||||
}).
|
}).
|
||||||
Lines(
|
Lines(
|
||||||
Contains("four").IsSelected(),
|
Contains("four"),
|
||||||
Contains("three"),
|
Contains("three"),
|
||||||
Contains("base"),
|
Contains("base").IsSelected(),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -79,8 +79,8 @@ var CherryPickDuringRebase = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
Contains("--- Pending rebase todos ---"),
|
Contains("--- Pending rebase todos ---"),
|
||||||
Contains("pick CI two"),
|
Contains("pick CI two"),
|
||||||
Contains("--- Commits ---"),
|
Contains("--- Commits ---"),
|
||||||
Contains(" CI three").IsSelected(),
|
Contains(" CI three"),
|
||||||
Contains(" CI one"),
|
Contains(" CI one").IsSelected(),
|
||||||
Contains(" CI base"),
|
Contains(" CI base"),
|
||||||
).
|
).
|
||||||
Tap(func() {
|
Tap(func() {
|
||||||
@ -88,8 +88,8 @@ var CherryPickDuringRebase = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
}).
|
}).
|
||||||
Lines(
|
Lines(
|
||||||
Contains("CI two"),
|
Contains("CI two"),
|
||||||
Contains("CI three").IsSelected(),
|
Contains("CI three"),
|
||||||
Contains("CI one"),
|
Contains("CI one").IsSelected(),
|
||||||
Contains("CI base"),
|
Contains("CI base"),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
@ -63,9 +63,10 @@ var CherryPickMerge = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
t.Views().Information().Content(DoesNotContain("commit copied"))
|
t.Views().Information().Content(DoesNotContain("commit copied"))
|
||||||
}).
|
}).
|
||||||
Lines(
|
Lines(
|
||||||
Contains("Merge branch 'second-branch'").IsSelected(),
|
Contains("Merge branch 'second-branch'"),
|
||||||
Contains("base"),
|
Contains("base").IsSelected(),
|
||||||
)
|
).
|
||||||
|
SelectPreviousItem()
|
||||||
|
|
||||||
t.Views().Main().ContainsLines(
|
t.Views().Main().ContainsLines(
|
||||||
Contains("Merge branch 'second-branch'"),
|
Contains("Merge branch 'second-branch'"),
|
||||||
|
@ -70,9 +70,9 @@ var CherryPickRange = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
t.Views().Information().Content(DoesNotContain("commits copied"))
|
t.Views().Information().Content(DoesNotContain("commits copied"))
|
||||||
}).
|
}).
|
||||||
Lines(
|
Lines(
|
||||||
Contains("four").IsSelected(),
|
Contains("four"),
|
||||||
Contains("three"),
|
Contains("three"),
|
||||||
Contains("two"),
|
Contains("two").IsSelected(),
|
||||||
Contains("one"),
|
Contains("one"),
|
||||||
Contains("base"),
|
Contains("base"),
|
||||||
)
|
)
|
||||||
|
@ -43,8 +43,8 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
Confirm()
|
Confirm()
|
||||||
}).
|
}).
|
||||||
Lines(
|
Lines(
|
||||||
Contains("three").IsSelected(),
|
Contains("three"),
|
||||||
Contains("one"),
|
Contains("one").IsSelected(),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user