diff --git a/pkg/gui/controllers/helpers/cherry_pick_helper.go b/pkg/gui/controllers/helpers/cherry_pick_helper.go index 359d1cbc2..079fdedcf 100644 --- a/pkg/gui/controllers/helpers/cherry_pick_helper.go +++ b/pkg/gui/controllers/helpers/cherry_pick_helper.go @@ -40,6 +40,14 @@ func (self *CherryPickHelper) CopyRange(commitsList []*models.Commit, context ty return err } + // After a paste the buffer is hidden but not cleared, so the user + // thinks they're starting fresh. Clear it before adding so the new + // copy replaces the old one. + if self.getData().DidPaste { + self.getData().CherryPickedCommits = nil + self.getData().DidPaste = false + } + commitSet := self.getData().SelectedHashSet() allCommitsCopied := lo.EveryBy(commitsList[startIdx:endIdx+1], func(commit *models.Commit) bool { @@ -59,8 +67,6 @@ func (self *CherryPickHelper) CopyRange(commitsList []*models.Commit, context ty } } - self.getData().DidPaste = false - self.rerender() return nil } diff --git a/pkg/integration/tests/cherry_pick/cherry_pick_range_after_paste.go b/pkg/integration/tests/cherry_pick/cherry_pick_range_after_paste.go index 9441c0596..4f1cf180a 100644 --- a/pkg/integration/tests/cherry_pick/cherry_pick_range_after_paste.go +++ b/pkg/integration/tests/cherry_pick/cherry_pick_range_after_paste.go @@ -81,10 +81,7 @@ var CherryPickRangeAfterPaste = NewIntegrationTest(NewIntegrationTestArgs{ Press(keys.Universal.RangeSelectDown). Press(keys.Commits.CherryPickCopy). Tap(func() { - /* EXPECTED: t.Views().Information().Content(Contains("3 commits copied")) - ACTUAL: */ - t.Views().Information().Content(Contains("1 commit copied")) }) t.Views().Commits(). @@ -94,14 +91,10 @@ var CherryPickRangeAfterPaste = NewIntegrationTest(NewIntegrationTestArgs{ Tap(func() { t.ExpectPopup().Alert(). Title(Equals("Cherry-pick")). - /* EXPECTED: Content(Equals("Are you sure you want to cherry-pick the 3 copied commit(s) onto this branch?")). - ACTUAL: */ - Content(Equals("Are you sure you want to cherry-pick the 1 copied commit(s) onto this branch?")). Confirm() }) - /* EXPECTED: t.Views().Commits().Lines( Contains("four"), Contains("three"), @@ -109,11 +102,5 @@ var CherryPickRangeAfterPaste = NewIntegrationTest(NewIntegrationTestArgs{ Contains("five"), Contains("base").IsSelected(), ) - ACTUAL: */ - t.Views().Commits().Lines( - Contains("two"), - Contains("five"), - Contains("base").IsSelected(), - ) }, })