summaryrefslogtreecommitdiffstats
path: root/pkg/gui/patch_options_panel.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2019-11-05 17:57:59 +1100
committerJesse Duffield <jessedduffield@gmail.com>2019-11-05 19:22:01 +1100
commit10fe88a2cf79d525f4dfa767b2d0fab1793127e8 (patch)
tree127b3cf0d06c9ddd114a3863bca01519ffab92fc /pkg/gui/patch_options_panel.go
parent1a38bfb76d5e2f1b0f03c35fc17f463b0ecf54f1 (diff)
more work on managing focus when applying patch command
Diffstat (limited to 'pkg/gui/patch_options_panel.go')
-rw-r--r--pkg/gui/patch_options_panel.go33
1 files changed, 26 insertions, 7 deletions
diff --git a/pkg/gui/patch_options_panel.go b/pkg/gui/patch_options_panel.go
index a55e0d4a7..a966040e2 100644
--- a/pkg/gui/patch_options_panel.go
+++ b/pkg/gui/patch_options_panel.go
@@ -60,11 +60,29 @@ func (gui *Gui) getPatchCommitIndex() int {
return -1
}
+func (gui *Gui) validateNormalWorkingTreeState() (bool, error) {
+ if gui.State.WorkingTreeState != "normal" {
+ return false, gui.createErrorPanel(gui.g, gui.Tr.SLocalize("CantPatchWhileRebasingError"))
+ }
+ return true, nil
+}
+
+func (gui *Gui) returnFocusFromLineByLinePanelIfNecessary() error {
+ if gui.State.Contexts["main"] == "patch-building" {
+ return gui.handleEscapePatchBuildingPanel(gui.g, nil)
+ }
+ return nil
+}
+
func (gui *Gui) handleDeletePatchFromCommit() error {
if ok, err := gui.validateNormalWorkingTreeState(); !ok {
return err
}
+ if err := gui.returnFocusFromLineByLinePanelIfNecessary(); err != nil {
+ return err
+ }
+
return gui.WithWaitingStatus(gui.Tr.SLocalize("RebasingStatus"), func() error {
commitIndex := gui.getPatchCommitIndex()
err := gui.GitCommand.DeletePatchesFromCommit(gui.State.Commits, commitIndex, gui.GitCommand.PatchManager)
@@ -77,6 +95,10 @@ func (gui *Gui) handleMovePatchToSelectedCommit() error {
return err
}
+ if err := gui.returnFocusFromLineByLinePanelIfNecessary(); err != nil {
+ return err
+ }
+
return gui.WithWaitingStatus(gui.Tr.SLocalize("RebasingStatus"), func() error {
commitIndex := gui.getPatchCommitIndex()
err := gui.GitCommand.MovePatchToSelectedCommit(gui.State.Commits, commitIndex, gui.State.Panels.Commits.SelectedLine, gui.GitCommand.PatchManager)
@@ -84,18 +106,15 @@ func (gui *Gui) handleMovePatchToSelectedCommit() error {
})
}
-func (gui *Gui) validateNormalWorkingTreeState() (bool, error) {
- if gui.State.WorkingTreeState != "normal" {
- return false, gui.createErrorPanel(gui.g, gui.Tr.SLocalize("CantPatchWhileRebasingError"))
- }
- return true, nil
-}
-
func (gui *Gui) handlePullPatchIntoWorkingTree() error {
if ok, err := gui.validateNormalWorkingTreeState(); !ok {
return err
}
+ if err := gui.returnFocusFromLineByLinePanelIfNecessary(); err != nil {
+ return err
+ }
+
return gui.WithWaitingStatus(gui.Tr.SLocalize("RebasingStatus"), func() error {
commitIndex := gui.getPatchCommitIndex()
err := gui.GitCommand.PullPatchIntoIndex(gui.State.Commits, commitIndex, gui.GitCommand.PatchManager)