diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2019-11-10 15:24:20 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2019-11-10 16:18:25 +1100 |
commit | cd17b46b55e312b3ba4e3ab9d3d96a8eeb20fded (patch) | |
tree | e35db3d358e3937f5ac960802775ccbdb29581a6 /pkg/gui | |
parent | d0d92c7697c311071e2fc4b5cc9fa9278a9c300a (diff) |
reset patch builder when we've escaped from the building phase and nothing has been added
Diffstat (limited to 'pkg/gui')
-rw-r--r-- | pkg/gui/commit_files_panel.go | 8 | ||||
-rw-r--r-- | pkg/gui/patch_building_panel.go | 9 | ||||
-rw-r--r-- | pkg/gui/patch_options_panel.go | 2 |
3 files changed, 12 insertions, 7 deletions
diff --git a/pkg/gui/commit_files_panel.go b/pkg/gui/commit_files_panel.go index c0cab24cb..845f7b02d 100644 --- a/pkg/gui/commit_files_panel.go +++ b/pkg/gui/commit_files_panel.go @@ -136,7 +136,7 @@ func (gui *Gui) handleToggleFileForPatch(g *gocui.Gui, v *gocui.View) error { } toggleTheFile := func() error { - if gui.GitCommand.PatchManager.IsEmpty() { + if !gui.GitCommand.PatchManager.CommitSelected() { if err := gui.startPatchManager(); err != nil { return err } @@ -147,7 +147,7 @@ func (gui *Gui) handleToggleFileForPatch(g *gocui.Gui, v *gocui.View) error { return gui.refreshCommitFilesView() } - if !gui.GitCommand.PatchManager.IsEmpty() && gui.GitCommand.PatchManager.CommitSha != commitFile.Sha { + if gui.GitCommand.PatchManager.CommitSelected() && gui.GitCommand.PatchManager.CommitSha != commitFile.Sha { return gui.createConfirmationPanel(g, v, true, gui.Tr.SLocalize("DiscardPatch"), gui.Tr.SLocalize("DiscardPatchConfirm"), func(g *gocui.Gui, v *gocui.View) error { gui.GitCommand.PatchManager.Reset() return toggleTheFile() @@ -187,7 +187,7 @@ func (gui *Gui) handleEnterCommitFile(g *gocui.Gui, v *gocui.View) error { } enterTheFile := func() error { - if gui.GitCommand.PatchManager.IsEmpty() { + if !gui.GitCommand.PatchManager.CommitSelected() { if err := gui.startPatchManager(); err != nil { return err } @@ -202,7 +202,7 @@ func (gui *Gui) handleEnterCommitFile(g *gocui.Gui, v *gocui.View) error { return gui.refreshPatchBuildingPanel() } - if !gui.GitCommand.PatchManager.IsEmpty() && gui.GitCommand.PatchManager.CommitSha != commitFile.Sha { + if gui.GitCommand.PatchManager.CommitSelected() && gui.GitCommand.PatchManager.CommitSha != commitFile.Sha { return gui.createConfirmationPanel(g, v, false, gui.Tr.SLocalize("DiscardPatch"), gui.Tr.SLocalize("DiscardPatchConfirm"), func(g *gocui.Gui, v *gocui.View) error { gui.GitCommand.PatchManager.Reset() return enterTheFile() diff --git a/pkg/gui/patch_building_panel.go b/pkg/gui/patch_building_panel.go index 26196f6d1..5667b45da 100644 --- a/pkg/gui/patch_building_panel.go +++ b/pkg/gui/patch_building_panel.go @@ -5,7 +5,7 @@ import ( ) func (gui *Gui) refreshPatchBuildingPanel() error { - if gui.GitCommand.PatchManager.IsEmpty() { + if !gui.GitCommand.PatchManager.CommitSelected() { return gui.handleEscapePatchBuildingPanel(gui.g, nil) } @@ -87,11 +87,16 @@ func (gui *Gui) handleEscapePatchBuildingPanel(g *gocui.Gui, v *gocui.View) erro gui.State.Panels.LineByLine = nil gui.State.Contexts["main"] = "normal" + if gui.GitCommand.PatchManager.IsEmpty() { + gui.GitCommand.PatchManager.Reset() + gui.State.SplitMainPanel = false + } + return gui.switchFocus(gui.g, nil, gui.getCommitFilesView()) } func (gui *Gui) refreshSecondaryPatchPanel() error { - if !gui.GitCommand.PatchManager.IsEmpty() { + if gui.GitCommand.PatchManager.CommitSelected() { gui.State.SplitMainPanel = true secondaryView := gui.getSecondaryView() secondaryView.Highlight = true diff --git a/pkg/gui/patch_options_panel.go b/pkg/gui/patch_options_panel.go index 748f70365..52974bf8b 100644 --- a/pkg/gui/patch_options_panel.go +++ b/pkg/gui/patch_options_panel.go @@ -17,7 +17,7 @@ func (o *patchMenuOption) GetDisplayStrings(isFocused bool) []string { } func (gui *Gui) handleCreatePatchOptionsMenu(g *gocui.Gui, v *gocui.View) error { - if gui.GitCommand.PatchManager.IsEmpty() { + if !gui.GitCommand.PatchManager.CommitSelected() { return gui.createErrorPanel(gui.g, gui.Tr.SLocalize("NoPatchError")) } |