summaryrefslogtreecommitdiffstats
path: root/pkg/gui
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-08-23 11:23:32 +1000
committerJesse Duffield <jessedduffield@gmail.com>2020-08-23 14:29:18 +1000
commitbd661629720d38d10a06fab254266ec2968e3f0a (patch)
tree0fe7012373ffa5efb1934c73921909e26ffb3cee /pkg/gui
parent5cdfd41dca3ee2c080e8f3d40cfdc147e0b8a595 (diff)
fix up patch manager
Diffstat (limited to 'pkg/gui')
-rw-r--r--pkg/gui/commit_files_panel.go8
-rw-r--r--pkg/gui/context.go15
-rw-r--r--pkg/gui/patch_options_panel.go10
3 files changed, 21 insertions, 12 deletions
diff --git a/pkg/gui/commit_files_panel.go b/pkg/gui/commit_files_panel.go
index 5b51dc74e..65ac9a936 100644
--- a/pkg/gui/commit_files_panel.go
+++ b/pkg/gui/commit_files_panel.go
@@ -113,10 +113,6 @@ func (gui *Gui) handleEditCommitFile(g *gocui.Gui, v *gocui.View) error {
}
func (gui *Gui) handleToggleFileForPatch(g *gocui.Gui, v *gocui.View) error {
- if ok, err := gui.validateNormalWorkingTreeState(); !ok {
- return err
- }
-
commitFile := gui.getSelectedCommitFile()
if commitFile == nil {
gui.renderString("commitFiles", gui.Tr.SLocalize("NoCommiteFiles"))
@@ -172,10 +168,6 @@ func (gui *Gui) handleEnterCommitFile(g *gocui.Gui, v *gocui.View) error {
}
func (gui *Gui) enterCommitFile(selectedLineIdx int) error {
- if ok, err := gui.validateNormalWorkingTreeState(); !ok {
- return err
- }
-
commitFile := gui.getSelectedCommitFile()
if commitFile == nil {
gui.renderString("commitFiles", gui.Tr.SLocalize("NoCommiteFiles"))
diff --git a/pkg/gui/context.go b/pkg/gui/context.go
index 7b74d94a3..b198cb7e9 100644
--- a/pkg/gui/context.go
+++ b/pkg/gui/context.go
@@ -343,6 +343,21 @@ func (gui *Gui) viewTabContextMap() map[string][]tabContext {
}
}
+func (gui *Gui) currentContextKeyIgnoringPopups() string {
+ stack := gui.State.ContextStack
+
+ for i := range stack {
+ reversedIndex := len(stack) - 1 - i
+ context := stack[reversedIndex]
+ kind := stack[reversedIndex].GetKind()
+ if kind != TEMPORARY_POPUP && kind != PERSISTENT_POPUP {
+ return context.GetKey()
+ }
+ }
+
+ return ""
+}
+
func (gui *Gui) switchContext(c Context) error {
gui.g.Update(func(*gocui.Gui) error {
// push onto stack
diff --git a/pkg/gui/patch_options_panel.go b/pkg/gui/patch_options_panel.go
index 1eb6cffa7..d2e1ba072 100644
--- a/pkg/gui/patch_options_panel.go
+++ b/pkg/gui/patch_options_panel.go
@@ -26,7 +26,7 @@ func (gui *Gui) handleCreatePatchOptionsMenu(g *gocui.Gui, v *gocui.View) error
},
}
- if gui.GitCommand.PatchManager.CanRebase {
+ if gui.GitCommand.PatchManager.CanRebase && gui.workingTreeState() == "normal" {
menuItems = append(menuItems, []*menuItem{
{
displayString: fmt.Sprintf("remove patch from original commit (%s)", gui.GitCommand.PatchManager.To),
@@ -77,9 +77,6 @@ func (gui *Gui) validateNormalWorkingTreeState() (bool, error) {
if gui.GitCommand.WorkingTreeState() != "normal" {
return false, gui.createErrorPanel(gui.Tr.SLocalize("CantPatchWhileRebasingError"))
}
- if gui.GitCommand.WorkingTreeState() != "normal" {
- return false, gui.createErrorPanel(gui.Tr.SLocalize("CantPatchWhileRebasingError"))
- }
return true, nil
}
@@ -183,5 +180,10 @@ func (gui *Gui) handleApplyPatch(reverse bool) error {
func (gui *Gui) handleResetPatch() error {
gui.GitCommand.PatchManager.Reset()
+ if gui.currentContextKeyIgnoringPopups() == MAIN_PATCH_BUILDING_CONTEXT_KEY {
+ if err := gui.switchContext(gui.Contexts.CommitFiles.Context); err != nil {
+ return err
+ }
+ }
return gui.refreshCommitFilesView()
}