mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 15:46:26 -04:00
Clear cherry-pick buffer when copying after a paste
After a successful paste DidPaste is true, hiding the "X commits copied" indicator but leaving the buffer populated. From the user's perspective this looks like a clean slate, so a new shift+C should start fresh. It is important to reset DidPaste first, before populating the buffer with the new commits, because otherwise each loop iteration would overwrite the previous one since Add() rebuilds the set via SelectedHashSet() which returns empty while DidPaste is set.
This commit is contained in:
parent
f264d43a1a
commit
7a2d1ab544
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
)
|
||||
},
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue