diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-08-23 12:20:49 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-08-23 14:29:18 +1000 |
commit | 94601b4dc951de9b1efa08120148d2d9766b637c (patch) | |
tree | 0541d8468d78a58f4a2ef069323de475be13d29c /pkg | |
parent | 9ca0073cd7680d2417d4bb0a38a7b02df3dfd651 (diff) |
use context to return to the correct view
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/gui/branches_panel.go | 56 | ||||
-rw-r--r-- | pkg/gui/cherry_picking.go | 6 | ||||
-rw-r--r-- | pkg/gui/commit_files_panel.go | 18 | ||||
-rw-r--r-- | pkg/gui/commits_panel.go | 42 | ||||
-rw-r--r-- | pkg/gui/confirmation_panel.go | 33 | ||||
-rw-r--r-- | pkg/gui/diffing.go | 2 | ||||
-rw-r--r-- | pkg/gui/files_panel.go | 36 | ||||
-rw-r--r-- | pkg/gui/filtering.go | 6 | ||||
-rw-r--r-- | pkg/gui/filtering_menu_panel.go | 2 | ||||
-rw-r--r-- | pkg/gui/git_flow.go | 2 | ||||
-rw-r--r-- | pkg/gui/gui.go | 16 | ||||
-rw-r--r-- | pkg/gui/merge_panel.go | 6 | ||||
-rw-r--r-- | pkg/gui/patch_options_panel.go | 6 | ||||
-rw-r--r-- | pkg/gui/quitting.go | 6 | ||||
-rw-r--r-- | pkg/gui/rebase_options_panel.go | 6 | ||||
-rw-r--r-- | pkg/gui/reflog_panel.go | 6 | ||||
-rw-r--r-- | pkg/gui/remote_branches_panel.go | 12 | ||||
-rw-r--r-- | pkg/gui/remotes_panel.go | 16 | ||||
-rw-r--r-- | pkg/gui/staging_panel.go | 6 | ||||
-rw-r--r-- | pkg/gui/stash_panel.go | 20 | ||||
-rw-r--r-- | pkg/gui/sub_commits_panel.go | 6 | ||||
-rw-r--r-- | pkg/gui/tags_panel.go | 10 | ||||
-rw-r--r-- | pkg/gui/undoing.go | 6 | ||||
-rw-r--r-- | pkg/gui/updates.go | 15 |
24 files changed, 124 insertions, 216 deletions
diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go index d79e72b49..36c8ab112 100644 --- a/pkg/gui/branches_panel.go +++ b/pkg/gui/branches_panel.go @@ -115,10 +115,8 @@ func (gui *Gui) handleForceCheckout(g *gocui.Gui, v *gocui.View) error { title := gui.Tr.SLocalize("ForceCheckoutBranch") return gui.ask(askOpts{ - returnToView: v, - returnFocusOnClose: true, - title: title, - prompt: message, + title: title, + prompt: message, handleConfirm: func() error { if err := gui.GitCommand.Checkout(branch.Name, commands.CheckoutOptions{Force: true}); err != nil { _ = gui.surfaceError(err) @@ -160,10 +158,9 @@ func (gui *Gui) handleCheckoutRef(ref string, options handleCheckoutRefOptions) if strings.Contains(err.Error(), "Please commit your changes or stash them before you switch branch") { // offer to autostash changes return gui.ask(askOpts{ - returnToView: gui.getBranchesView(), - returnFocusOnClose: true, - title: gui.Tr.SLocalize("AutoStashTitle"), - prompt: gui.Tr.SLocalize("AutoStashPrompt"), + + title: gui.Tr.SLocalize("AutoStashTitle"), + prompt: gui.Tr.SLocalize("AutoStashPrompt"), handleConfirm: func() error { if err := gui.GitCommand.StashSave(gui.Tr.SLocalize("StashPrefix") + ref); err != nil { return gui.surfaceError(err) @@ -195,15 +192,14 @@ func (gui *Gui) handleCheckoutRef(ref string, options handleCheckoutRefOptions) } func (gui *Gui) handleCheckoutByName(g *gocui.Gui, v *gocui.View) error { - return gui.prompt(v, gui.Tr.SLocalize("BranchName")+":", "", func(response string) error { + return gui.prompt(gui.Tr.SLocalize("BranchName")+":", "", func(response string) error { return gui.handleCheckoutRef(response, handleCheckoutRefOptions{ onRefNotFound: func(ref string) error { return gui.ask(askOpts{ - returnToView: v, - returnFocusOnClose: true, - title: gui.Tr.SLocalize("BranchNotFoundTitle"), - prompt: fmt.Sprintf("%s %s%s", gui.Tr.SLocalize("BranchNotFoundPrompt"), ref, "?"), + + title: gui.Tr.SLocalize("BranchNotFoundTitle"), + prompt: fmt.Sprintf("%s %s%s", gui.Tr.SLocalize("BranchNotFoundPrompt"), ref, "?"), handleConfirm: func() error { return gui.createNewBranchWithName(ref) }, @@ -266,10 +262,9 @@ func (gui *Gui) deleteNamedBranch(selectedBranch *commands.Branch, force bool) e ) return gui.ask(askOpts{ - returnToView: gui.getBranchesView(), - returnFocusOnClose: true, - title: title, - prompt: message, + + title: title, + prompt: message, handleConfirm: func() error { if err := gui.GitCommand.DeleteBranch(selectedBranch.Name, force); err != nil { errMessage := err.Error() @@ -304,10 +299,9 @@ func (gui *Gui) mergeBranchIntoCheckedOutBranch(branchName string) error { ) return gui.ask(askOpts{ - returnToView: gui.getBranchesView(), - returnFocusOnClose: true, - title: gui.Tr.SLocalize("MergingTitle"), - prompt: prompt, + + title: gui.Tr.SLocalize("MergingTitle"), + prompt: prompt, handleConfirm: func() error { err := gui.GitCommand.Merge(branchName, commands.MergeOpts{}) return gui.handleGenericMergeCommandResult(err) @@ -347,10 +341,9 @@ func (gui *Gui) handleRebaseOntoBranch(selectedBranchName string) error { ) return gui.ask(askOpts{ - returnToView: gui.getBranchesView(), - returnFocusOnClose: true, - title: gui.Tr.SLocalize("RebasingTitle"), - prompt: prompt, + + title: gui.Tr.SLocalize("RebasingTitle"), + prompt: prompt, handleConfirm: func() error { err := gui.GitCommand.RebaseBranch(selectedBranchName) return gui.handleGenericMergeCommandResult(err) @@ -422,7 +415,7 @@ func (gui *Gui) handleRenameBranch(g *gocui.Gui, v *gocui.View) error { // way to get it to show up in the reflog) promptForNewName := func() error { - return gui.prompt(v, gui.Tr.SLocalize("NewBranchNamePrompt")+" "+branch.Name+":", "", func(newBranchName string) error { + return gui.prompt(gui.Tr.SLocalize("NewBranchNamePrompt")+" "+branch.Name+":", "", func(newBranchName string) error { if err := gui.GitCommand.RenameBranch(branch.Name, newBranchName); err != nil { return gui.surfaceError(err) } @@ -445,11 +438,10 @@ func (gui *Gui) handleRenameBranch(g *gocui.Gui, v *gocui.View) error { } return gui.ask(askOpts{ - returnToView: v, - returnFocusOnClose: true, - title: gui.Tr.SLocalize("renameBranch"), - prompt: gui.Tr.SLocalize("RenameBranchWarning"), - handleConfirm: promptForNewName, + + title: gui.Tr.SLocalize("renameBranch"), + prompt: gui.Tr.SLocalize("RenameBranchWarning"), + handleConfirm: promptForNewName, }) } @@ -475,7 +467,7 @@ func (gui *Gui) handleNewBranchOffCurrentItem() error { }, ) - return gui.prompt(gui.getCurrentSideView(), message, "", func(response string) error { + return gui.prompt(message, "", func(response string) error { if err := gui.GitCommand.NewBranch(response, item.ID()); err != nil { return err } diff --git a/pkg/gui/cherry_picking.go b/pkg/gui/cherry_picking.go index 1165a43a1..04e7517b7 100644 --- a/pkg/gui/cherry_picking.go +++ b/pkg/gui/cherry_picking.go @@ -146,10 +146,8 @@ func (gui *Gui) HandlePasteCommits() error { } return gui.ask(askOpts{ - returnToView: gui.getCommitsView(), - returnFocusOnClose: true, - title: gui.Tr.SLocalize("CherryPick"), - prompt: gui.Tr.SLocalize("SureCherryPick"), + title: gui.Tr.SLocalize("CherryPick"), + prompt: gui.Tr.SLocalize("SureCherryPick"), handleConfirm: func() error { return gui.WithWaitingStatus(gui.Tr.SLocalize("CherryPickingStatus"), func() error { err := gui.GitCommand.CherryPickCommits(gui.State.Modes.CherryPicking.CherryPickedCommits) diff --git a/pkg/gui/commit_files_panel.go b/pkg/gui/commit_files_panel.go index 65ac9a936..505beda0e 100644 --- a/pkg/gui/commit_files_panel.go +++ b/pkg/gui/commit_files_panel.go @@ -59,10 +59,8 @@ func (gui *Gui) handleDiscardOldFileChange(g *gocui.Gui, v *gocui.View) error { fileName := gui.State.CommitFiles[gui.State.Panels.CommitFiles.SelectedLineIdx].Name return gui.ask(askOpts{ - returnToView: v, - returnFocusOnClose: true, - title: gui.Tr.SLocalize("DiscardFileChangesTitle"), - prompt: gui.Tr.SLocalize("DiscardFileChangesPrompt"), + title: gui.Tr.SLocalize("DiscardFileChangesTitle"), + prompt: gui.Tr.SLocalize("DiscardFileChangesPrompt"), handleConfirm: func() error { return gui.WithWaitingStatus(gui.Tr.SLocalize("RebasingStatus"), func() error { if err := gui.GitCommand.DiscardOldFileChanges(gui.State.Commits, gui.State.Panels.Commits.SelectedLineIdx, fileName); err != nil { @@ -139,10 +137,8 @@ func (gui *Gui) handleToggleFileForPatch(g *gocui.Gui, v *gocui.View) error { if gui.GitCommand.PatchManager.Active() && gui.GitCommand.PatchManager.To != commitFile.Parent { return gui.ask(askOpts{ - returnToView: v, - returnFocusOnClose: true, - title: gui.Tr.SLocalize("DiscardPatch"), - prompt: gui.Tr.SLocalize("DiscardPatchConfirm"), + title: gui.Tr.SLocalize("DiscardPatch"), + prompt: gui.Tr.SLocalize("DiscardPatchConfirm"), handleConfirm: func() error { gui.GitCommand.PatchManager.Reset() return toggleTheFile() @@ -189,10 +185,8 @@ func (gui *Gui) enterCommitFile(selectedLineIdx int) error { if gui.GitCommand.PatchManager.Active() && gui.GitCommand.PatchManager.To != commitFile.Parent { return gui.ask(askOpts{ - returnToView: gui.getCommitFilesView(), - returnFocusOnClose: false, - title: gui.Tr.SLocalize("DiscardPatch"), - prompt: gui.Tr.SLocalize("DiscardPatchConfirm"), + title: gui.Tr.SLocalize("DiscardPatch"), + prompt: gui.Tr.SLocalize("DiscardPatchConfirm"), handleConfirm: func() error { gui.GitCommand.PatchManager.Reset() return enterTheFile(selectedLineIdx) diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index 007f3f447..200fea7af 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -135,10 +135,8 @@ func (gui *Gui) handleCommitSquashDown(g *gocui.Gui, v *gocui.View) error { } return gui.ask(askOpts{ - returnToView: v, - returnFocusOnClose: true, - title: gui.Tr.SLocalize("Squash"), - prompt: gui.Tr.SLocalize("SureSquashThisCommit"), + title: gui.Tr.SLocalize("Squash"), + prompt: gui.Tr.SLocalize("SureSquashThisCommit"), handleConfirm: func() error { return gui.WithWaitingStatus(gui.Tr.SLocalize("SquashingStatus"), func() error { err := gui.GitCommand.InteractiveRebase(gui.State.Commits, gui.State.Panels.Commits.SelectedLineIdx, "squash") @@ -166,10 +164,8 @@ func (gui *Gui) handleCommitFixup(g *gocui.Gui, v *gocui.View) error { } return gui.ask(askOpts{ - returnToView: v, - returnFocusOnClose: true, - title: gui.Tr.SLocalize("Fixup"), - prompt: gui.Tr.SLocalize("SureFixupThisCommit"), + title: gui.Tr.SLocalize("Fixup"), + prompt: gui.Tr.SLocalize("SureFixupThisCommit"), handleConfirm: func() error { return gui.WithWaitingStatus(gui.Tr.SLocalize("FixingStatus"), func() error { err := gui.GitCommand.InteractiveRebase(gui.State.Commits, gui.State.Panels.Commits.SelectedLineIdx, "fixup") @@ -206,7 +202,7 @@ func (gui *Gui) handleRenameCommit(g *gocui.Gui, v *gocui.View) error { return gui.surfaceError(err) } - return gui.prompt(v, gui.Tr.SLocalize("renameCommit"), message, func(response string) error { + return gui.prompt(gui.Tr.SLocalize("renameCommit"), message, func(response string) error { if err := gui.GitCommand.RenameCommit(response); err != nil { return gui.surfaceError(err) } @@ -279,10 +275,8 @@ func (gui *Gui) handleCommitDelete(g *gocui.Gui, v *gocui.View) error { } return gui.ask(askOpts{ - returnToView: v, - returnFocusOnClose: true, - title: gui.Tr.SLocalize("DeleteCommitTitle"), - prompt: gui.Tr.SLocalize("DeleteCommitPrompt"), + title: gui.Tr.SLocalize("DeleteCommitTitle"), + prompt: gui.Tr.SLocalize("DeleteCommitPrompt"), handleConfirm: func() error { return gui.WithWaitingStatus(gui.Tr.SLocalize("DeletingStatus"), func() error { err := gui.GitCommand.InteractiveRebase(gui.State.Commits, gui.State.Panels.Commits.SelectedLineIdx, "drop") @@ -371,10 +365,8 @@ func (gui *Gui) handleCommitAmendTo(g *gocui.Gui, v *gocui.View) error { } return gui.ask(askOpts{ - returnToView: v, - returnFocusOnClose: true, - title: gui.Tr.SLocalize("AmendCommitTitle"), - prompt: gui.Tr.SLocalize("AmendCommitPrompt"), + title: gui.Tr.SLocalize("AmendCommitTitle"), + prompt: gui.Tr.SLocalize("AmendCommitPrompt"), handleConfirm: func() error { return gui.WithWaitingStatus(gui.Tr.SLocalize("AmendingStatus"), func() error { err := gui.GitCommand.AmendTo(gui.State.Commits[gui.State.Panels.Commits.SelectedLineIdx].Sha) @@ -447,9 +439,7 @@ func (gui *Gui) handleCreateFixupCommit(g *gocui.Gui, v *gocui.View) error { } return gui.ask(askOpts{ - returnToView: v, - returnFocusOnClose: true, - title: gui.Tr.SLocalize("CreateFixupCommit"), + title: gui.Tr.SLocalize("CreateFixupCommit"), prompt: gui.Tr.TemplateLocalize( "SureCreateFixupCommit", Teml{ @@ -477,9 +467,7 @@ func (gui *Gui) handleSquashAllAboveFixupCommits(g *gocui.Gui, v *gocui.View) er } return gui.ask(askOpts{ - returnToView: v, - returnFocusOnClose: true, - title: gui.Tr.SLocalize("SquashAboveCommits"), + title: gui.Tr.SLocalize("SquashAboveCommits"), prompt: gui.Tr.TemplateLocalize( "SureSquashAboveCommits", Teml{ @@ -508,7 +496,7 @@ func (gui *Gui) handleTagCommit(g *gocui.Gui, v *gocui.View) error { } func (gui *Gui) handleCreateLightweightTag(commitSha string) error { - return gui.prompt(gui.getCommitsView(), gui.Tr.SLocalize("TagNameTitle"), "", func(response string) error { + return gui.prompt(gui.Tr.SLocalize("TagNameTitle"), "", func(response string) error { if err := gui.GitCommand.CreateLightweightTag(response, commitSha); err != nil { return gui.surfaceError(err) } @@ -523,10 +511,8 @@ func (gui *Gui) handleCheckoutCommit(g *gocui.Gui, v *gocui.View) error { } return gui.ask(askOpts{ - returnToView: gui.getCommitsView(), - returnFocusOnClose: true, - title: gui.Tr.SLocalize("checkoutCommit"), - prompt: gui.Tr.SLocalize("SureCheckoutThisCommit"), + title: gui.Tr.SLocalize("checkoutCommit"), + prompt: gui.Tr.SLocalize("SureCheckoutThisCommit"), handleConfirm: func() error { return gui.handleCheckoutRef(commit.Sha, handleCheckoutRefOptions{}) }, diff --git a/pkg/gui/confirmation_panel.go b/pkg/gui/confirmation_panel.go index b74d45e3f..e9103b42a 100644 --- a/pkg/gui/confirmation_panel.go +++ b/pkg/gui/confirmation_panel.go @@ -16,7 +16,6 @@ import ( ) type createPopupPanelOpts struct { - returnToView *gocui.View hasLoader bool returnFocusOnClose bool editable bool @@ -28,7 +27,6 @@ type createPopupPanelOpts struct { } type askOpts struct { - returnToView *gocui.View returnFocusOnClose bool title string prompt string @@ -38,30 +36,25 @@ type askOpts struct { func (gui *Gui) createLoaderPanel(currentView *gocui.View, prompt string) error { return gui.createPopupPanel(createPopupPanelOpts{ - returnToView: currentView, - prompt: prompt, - hasLoader: true, - returnFocusOnClose: true, + prompt: prompt, + hasLoader: true, }) } func (gui *Gui) ask(opts askOpts) error { return gui.createPopupPanel(createPopupPanelOpts{ - returnToView: opts.returnToView, - title: opts.title, - prompt: opts.prompt, - returnFocusOnClose: opts.returnFocusOnClose, - handleConfirm: opts.handleConfirm, - handleClose: opts.handleClose, + title: opts.title, + prompt: opts.prompt, + + handleConfirm: opts.handleConfirm, + handleClose: opts.handleClose, }) } -func (gui *Gui) prompt(currentView *gocui.View, title string, initialContent string, handleConfirm func(string) error) error { +func (gui *Gui) prompt(title string, initialContent string, handleConfirm func(string) error) error { return gui.createPopupPanel(createPopupPanelOpts{ - returnToView: currentView, title: title, prompt: initialContent, - returnFocusOnClose: true, editable: true, handleConfirmPrompt: handleConfirm, }) @@ -146,7 +139,7 @@ func (gui *Gui) getConfirmationPanelDimensions(wrap bool, prompt string) (int, i height/2 + panelHeight/2 } -func (gui *Gui) prepareConfirmationPanel(currentView *gocui.View, title, prompt string, hasLoader bool) (*gocui.View, error) { +func (gui *Gui) prepareConfirmationPanel(title, prompt string, hasLoader bool) (*gocui.View, error) { x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(true, prompt) confirmationView, err := gui.g.SetView("confirmation", x0, y0, x1, y1, 0) if err != nil { @@ -175,7 +168,7 @@ func (gui *Gui) createPopupPanel(opts createPopupPanelOpts) error { gui.Log.Error(err) } } - confirmationView, err := gui.prepareConfirmationPanel(opts.returnToView, opts.title, opts.prompt, opts.hasLoader) + confirmationView, err := gui.prepareConfirmationPanel(opts.title, opts.prompt, opts.hasLoader) if err != nil { return err } @@ -232,10 +225,8 @@ func (gui *Gui) createErrorPanel(message string) error { } return gui.ask(askOpts{ - returnToView: gui.g.CurrentView(), - title: gui.Tr.SLocalize("Error"), - prompt: coloredMessage, - returnFocusOnClose: true, + title: gui.Tr.SLocalize("Error"), + prompt: coloredMessage, }) } diff --git a/pkg/gui/diffing.go b/pkg/gui/diffing.go index c3cc40fa0..ef7919273 100644 --- a/pkg/gui/diffing.go +++ b/pkg/gui/diffing.go @@ -127,7 +127,7 @@ func (gui *Gui) handleCreateDiffingMenuPanel(g *gocui.Gui, v *gocui.View) error { displayString: gui.Tr.SLocalize("enterRefToDiff"), onPress: func() error { - return gui.prompt(v, gui.Tr.SLocalize("enteRefName"), "", func(response string) error { + return gui.prompt(gui.Tr.SLocalize("enteRefName"), "", func(response string) error { gui.State.Modes.Diffing.Ref = strings.TrimSpace(response) return gui.refreshSidePanels(refreshOptions{mode: ASYNC}) }) diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index 4f52cb86c..a8aa02436 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -232,10 +232,8 @@ func (gui *Gui) handleIgnoreFile(g *gocui.Gui, v *gocui.View) error { if file.Tracked { return gui.ask(askOpts{ - returnToView: gui.g.CurrentView(), - returnFocusOnClose: true, - title: gui.Tr.SLocalize("IgnoreTracked"), - prompt: gui.Tr.SLocalize("IgnoreTrackedPrompt"), + title: gui.Tr.SLocalize("IgnoreTracked"), + prompt: gui.Tr.SLocalize("IgnoreTrackedPrompt"), handleConfirm: func() error { if err := gui.GitCommand.Ignore(file.Name); err != nil { return err @@ -304,10 +302,8 @@ func (gui *Gui) handleCommitPress() error { func (gui *Gui) promptToStageAllAndRetry(retry func() error) error { return gui.ask(askOpts{ - returnToView: gui.getFilesView(), - returnFocusOnClose: true, - title: gui.Tr.SLocalize("NoFilesStagedTitle"), - prompt: gui.Tr.SLocalize("NoFilesStagedPrompt"), + title: gui.Tr.SLocalize("NoFilesStagedTitle"), + prompt: gui.Tr.SLocalize("NoFilesStagedPrompt"), handleConfirm: func() error { if err := gui.GitCommand.StageAll(); err != nil { return gui.surfaceError(err) @@ -333,10 +329,8 @@ func (gui *Gui) handleAmendCommitPress() error { } return gui.ask(askOpts{ - returnToView: gui.getFilesView(), - returnFocusOnClose: true, - title: strings.Title(gui.Tr.SLocalize("AmendLastCommit")), - prompt: gui.Tr.SLocalize("SureToAmend"), + title: strings.Title(gui.Tr.SLocalize("AmendLastCommit")), + prompt: gui.Tr.SLocalize("SureToAmend"), handleConfirm: func() error { ok, err := gui.runSyncOrAsyncCommand(gui.GitCommand.AmendHead()) if err != nil { @@ -443,7 +437,7 @@ func (gui *Gui) handlePullFiles(g *gocui.Gui, v *gocui.View) error { } } - return gui.prompt(v, gui.Tr.SLocalize("EnterUpstream"), "origin/"+currentBranch.Name, func(upstream string) error { + return gui.prompt(gui.Tr.SLocalize("EnterUpstream"), "origin/"+currentBranch.Name, func(upstream string) error { if err := gui.GitCommand.SetUpstreamBranch(upstream); err != nil { errorMessage := err.Error() if strings.Contains(errorMessage, "does not exist") { @@ -512,10 +506,8 @@ func (gui *Gui) pushWithForceFlag(v *gocui.View, force bool, upstream string, ar err := gui.GitCommand.Push(branchName, force, upstream, args, gui.promptUserForCredential) if err != nil && !force && strings.Contains(err.Error(), "Updates were rejected") { gui.ask(askOpts{ - returnToView: v, - returnFocusOnClose: true, - title: gui.Tr.SLocalize("ForcePush"), - prompt: gui.Tr.SLocalize("ForcePushPrompt"), + title: gui.Tr.SLocalize("ForcePush"), + prompt: gui.Tr.SLocalize("ForcePushPrompt"), handleConfirm: func() error { return gui.pushWithForceFlag(v, true, upstream, args) }, @@ -552,7 +544,7 @@ func (gui *Gui) pushFiles(g *gocui.Gui, v *gocui.View) error { if gui.GitCommand.PushToCurrent { return gui.pushWithForceFlag(v, false, "", "--set-upstream") } else { - return gui.prompt(v, gui.Tr.SLocalize("EnterUpstream"), "origin "+currentBranch.Name, func(response string) error { + return gui.prompt(gui.Tr.SLocalize("EnterUpstream"), "origin "+currentBranch.Name, func(response string) error { return gui.pushWithForceFlag(v, false, response, "") }) } @@ -561,10 +553,8 @@ func (gui *Gui) pushFiles(g *gocui.Gui, v *gocui.View) error { } return gui.ask(askOpts{ - returnToView: v, - returnFocusOnClose: true, - title: gui.Tr.SLocalize("ForcePush"), - prompt: gui.Tr.SLocalize("ForcePushPrompt"), + title: gui.Tr.SLocalize("ForcePush"), + prompt: gui.Tr.SLocalize("ForcePushPrompt"), handleConfirm: func() error { return gui.pushWithForceFlag(v, true, "", "") }, @@ -601,7 +591,7 @@ func (gui *Gui) anyFilesWithMergeConflicts() bool { } func (gui *Gui) handleCustomCommand(g *gocui.Gui, v *gocui.View) error { - return gui.prompt(v, gui.Tr.SLocalize("CustomCommand"), "", func(command string) error { + return gui.prompt(gui.Tr.SLocalize("CustomCommand"), "", func(command string) error { gui.SubProcess = gui.OSCommand.RunCustomCommand(command) return gui.Errors.ErrSubProcess }) diff --git a/pkg/gui/filtering.go b/pkg/gui/filtering.go index 2faafe9f2..222e59d14 100644 --- a/pkg/gui/filtering.go +++ b/pkg/gui/filtering.go @@ -3,10 +3,8 @@ package gui func (gui *Gui) validateNotInFilterMode() (bool, error) { if gui.State.Modes.Filtering.Active() { err := gui.ask(askOpts{ - returnToView: gui.g.CurrentView(), - returnFocusOnClose: true, - title: gui.Tr.SLocalize("MustExitFilterModeTitle"), - prompt: gui.Tr.SLocalize("MustExitFilterModePrompt"), + title: gui.Tr.SLocalize("MustExitFilterModeTitle"), + prompt: gui.Tr.SLocalize("MustExitFilterModePrompt"), handleConfirm: func() error { return gui.exitFilterMode() }, diff --git a/pkg/gui/filtering_menu_panel.go b/pkg/gui/filtering_menu_panel.go index b70fc80b2..8925e1395 100644 --- a/pkg/gui/filtering_menu_panel.go +++ b/pkg/gui/filtering_menu_panel.go @@ -41,7 +41,7 @@ func (gui *Gui) handleCreateFilteringMenuPanel(g *gocui.Gui, v *gocui.View) erro menuItems = append(menuItems, &menuItem{ displayString: gui.Tr.SLocalize("filterPathOption"), onPress: func() error { - return gui.prompt(v, gui.Tr.SLocalize("enterFileName"), "", func(response string) error { + return gui.prompt(gui.Tr.SLocalize("enterFileName"), "", func(response string) error { gui.State.Modes.Filtering.Path = strings.TrimSpace(response) return gui.Errors.ErrRestart }) diff --git a/pkg/gui/git_flow.go b/pkg/gui/git_flow.go index 367dd3048..dc6827499 100644 --- a/pkg/gui/git_flow.go +++ b/pkg/gui/git_flow.go @@ -51,7 +51,7 @@ func (gui *Gui) handleCreateGitFlowMenu(g *gocui.Gui, v *gocui.View) error { startHandler := func(branchType string) func() error { return func() error { title := gui.Tr.TemplateLocalize("NewBranchNamePrompt", map[string]interface{}{"branchType": branchType}) - return gui.prompt(gui.getMenuView(), title, "", func(name string) error { + return gui.prompt(title, "", func(name string) error { subProcess := gui.OSCommand.PrepareSubProcess("git", "flow", branchType, "start", name) gui.SubProcess = subProcess return gui.Errors.ErrSubProcess diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index c4d0bdf25..88b146d7c 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -555,12 +555,10 @@ func (gui *Gui) showIntroPopupMessage(done chan struct{}) error { } return gui.ask(askOpts{ - returnToView: nil, - returnFocusOnClose: true, - title: "", - prompt: gui.Tr.SLocalize("IntroPopupMessage"), - handleConfirm: onConfirm, - handleClose: onConfirm, + title: "", + prompt: gui.Tr.SLocalize("IntroPopupMessage"), + handleConfirm: onConfirm, + handleClose: onConfirm, }) } @@ -588,10 +586,8 @@ func (gui *Gui) startBackgroundFetch() { err := gui.fetch(false) if err != nil && strings.Contains(err.Error(), "exit status 128") && isNew { _ = gui.ask(askOpts{ - returnToView: gui.g.CurrentView(), - returnFocusOnClose: true, - title: gui.Tr.SLocalize("NoAutomaticGitFetchTitle"), - prompt: gui.Tr.SLocalize("NoAutomaticGitFetchBody"), + title: gui.Tr.SLocalize("NoAutomaticGitFetchTitle"), + prompt: gui.Tr.SLocalize("NoAutomaticGitFetchBody"), }) } else { gui.goEvery(time.Second*60, gui.stopChan, func() error { diff --git a/pkg/gui/merge_panel.go b/pkg/gui/merge_panel.go index da54b01ed..aa4dbe00d 100644 --- a/pkg/gui/merge_panel.go +++ b/pkg/gui/merge_panel.go @@ -341,10 +341,8 @@ func (gui *Gui) promptToContinue() error { gui.takeOverScrolling() return gui.ask(askOpts{ - returnToView: gui.getFilesView(), - returnFocusOnClose: true, - title: "continue", - prompt: gui.Tr.SLocalize("ConflictsResolved"), + title: "continue", + prompt: gui.Tr.SLocalize("ConflictsResolved"), handleConfirm: func() error { return gui.genericMergeCommand("continue") }, diff --git a/pkg/gui/patch_options_panel.go b/pkg/gui/patch_options_panel.go index d2e1ba072..419efca23 100644 --- a/pkg/gui/patch_options_panel.go +++ b/pkg/gui/patch_options_panel.go @@ -138,10 +138,8 @@ func (gui *Gui) handlePullPatchIntoWorkingTree() error { if len(gui.trackedFiles()) > 0 { return gui.ask(askOpts{ - returnToView: gui.g.CurrentView(), - returnFocusOnClose: true, - title: gui.Tr.SLocalize("MustStashTitle"), - prompt: gui.Tr.SLocalize("MustStashWarning"), + title: gui.Tr.SLocalize("MustStashTitle"), + prompt: gui.Tr.SLocalize("MustStashWarning"), handleConfirm: func() error { return pull(true) }, diff --git a/pkg/gui/quitting.go b/pkg/gui/quitting.go index 297b4a474..fc24d2155 100644 --- a/pkg/gui/quitting.go +++ b/pkg/gui/quitting.go @@ -61,10 +61,8 @@ func (gui *Gui) quit() error { if gui.Config.GetUserConfig().GetBool("confirmOnQuit") { return gui.ask(askOpts{ - returnToView: gui.g.CurrentView(), - returnFocusOnClose: true, - title: "", - prompt: gui.Tr.SLocalize("ConfirmQuit"), + title: "", + prompt: gui.Tr.SLocalize("ConfirmQuit"), handleConfirm: func() error { return gocui.ErrQuit }, diff --git a/pkg/gui/rebase_options_panel.go b/pkg/gui/rebase_options_panel.go index 03422da24..656ef0bbc 100644 --- a/pkg/gui/rebase_options_panel.go +++ b/pkg/gui/rebase_options_panel.go @@ -77,10 +77,8 @@ func (gui *Gui) handleGenericMergeCommandResult(result error) error { return ni |