From 567e898e22d85a26676cce9cee585f4cd44d39dd Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 23 Aug 2024 22:14:54 +0200 Subject: [PATCH] Bugfix: don't allow dropping patches from a custom patch that was made in diffing mode The three nested `if` statements may looks strange, and you might wonder why we don't have single one with &&. The answer is that later in this branch we will add an `else` block to the middle one. --- .../controllers/switch_to_diff_files_controller.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/gui/controllers/switch_to_diff_files_controller.go b/pkg/gui/controllers/switch_to_diff_files_controller.go index 3a0898f5c..aa05640b3 100644 --- a/pkg/gui/controllers/switch_to_diff_files_controller.go +++ b/pkg/gui/controllers/switch_to_diff_files_controller.go @@ -62,10 +62,19 @@ func (self *SwitchToDiffFilesController) GetOnClick() func() error { func (self *SwitchToDiffFilesController) enter(ref types.Ref) error { commitFilesContext := self.c.Contexts().CommitFiles + canRebase := self.context.CanRebase() + if canRebase { + if self.c.Modes().Diffing.Active() { + if self.c.Modes().Diffing.Ref != ref.RefName() { + canRebase = false + } + } + } + commitFilesContext.SetSelection(0) commitFilesContext.SetRef(ref) commitFilesContext.SetTitleRef(ref.Description()) - commitFilesContext.SetCanRebase(self.context.CanRebase()) + commitFilesContext.SetCanRebase(canRebase) commitFilesContext.SetParentContext(self.context) commitFilesContext.SetWindowName(self.context.GetWindowName()) commitFilesContext.ClearSearchString()