1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-04 10:34:55 +02:00

use context to return to the correct view

This commit is contained in:
Jesse Duffield 2020-08-23 12:20:49 +10:00
parent 9ca0073cd7
commit 94601b4dc9
24 changed files with 124 additions and 216 deletions

View File

@ -115,10 +115,8 @@ func (gui *Gui) handleForceCheckout(g *gocui.Gui, v *gocui.View) error {
title := gui.Tr.SLocalize("ForceCheckoutBranch") title := gui.Tr.SLocalize("ForceCheckoutBranch")
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: v, title: title,
returnFocusOnClose: true, prompt: message,
title: title,
prompt: message,
handleConfirm: func() error { handleConfirm: func() error {
if err := gui.GitCommand.Checkout(branch.Name, commands.CheckoutOptions{Force: true}); err != nil { if err := gui.GitCommand.Checkout(branch.Name, commands.CheckoutOptions{Force: true}); err != nil {
_ = gui.surfaceError(err) _ = 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") { if strings.Contains(err.Error(), "Please commit your changes or stash them before you switch branch") {
// offer to autostash changes // offer to autostash changes
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: gui.getBranchesView(),
returnFocusOnClose: true, title: gui.Tr.SLocalize("AutoStashTitle"),
title: gui.Tr.SLocalize("AutoStashTitle"), prompt: gui.Tr.SLocalize("AutoStashPrompt"),
prompt: gui.Tr.SLocalize("AutoStashPrompt"),
handleConfirm: func() error { handleConfirm: func() error {
if err := gui.GitCommand.StashSave(gui.Tr.SLocalize("StashPrefix") + ref); err != nil { if err := gui.GitCommand.StashSave(gui.Tr.SLocalize("StashPrefix") + ref); err != nil {
return gui.surfaceError(err) 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 { 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{ return gui.handleCheckoutRef(response, handleCheckoutRefOptions{
onRefNotFound: func(ref string) error { onRefNotFound: func(ref string) error {
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: v,
returnFocusOnClose: true, title: gui.Tr.SLocalize("BranchNotFoundTitle"),
title: gui.Tr.SLocalize("BranchNotFoundTitle"), prompt: fmt.Sprintf("%s %s%s", gui.Tr.SLocalize("BranchNotFoundPrompt"), ref, "?"),
prompt: fmt.Sprintf("%s %s%s", gui.Tr.SLocalize("BranchNotFoundPrompt"), ref, "?"),
handleConfirm: func() error { handleConfirm: func() error {
return gui.createNewBranchWithName(ref) return gui.createNewBranchWithName(ref)
}, },
@ -266,10 +262,9 @@ func (gui *Gui) deleteNamedBranch(selectedBranch *commands.Branch, force bool) e
) )
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: gui.getBranchesView(),
returnFocusOnClose: true, title: title,
title: title, prompt: message,
prompt: message,
handleConfirm: func() error { handleConfirm: func() error {
if err := gui.GitCommand.DeleteBranch(selectedBranch.Name, force); err != nil { if err := gui.GitCommand.DeleteBranch(selectedBranch.Name, force); err != nil {
errMessage := err.Error() errMessage := err.Error()
@ -304,10 +299,9 @@ func (gui *Gui) mergeBranchIntoCheckedOutBranch(branchName string) error {
) )
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: gui.getBranchesView(),
returnFocusOnClose: true, title: gui.Tr.SLocalize("MergingTitle"),
title: gui.Tr.SLocalize("MergingTitle"), prompt: prompt,
prompt: prompt,
handleConfirm: func() error { handleConfirm: func() error {
err := gui.GitCommand.Merge(branchName, commands.MergeOpts{}) err := gui.GitCommand.Merge(branchName, commands.MergeOpts{})
return gui.handleGenericMergeCommandResult(err) return gui.handleGenericMergeCommandResult(err)
@ -347,10 +341,9 @@ func (gui *Gui) handleRebaseOntoBranch(selectedBranchName string) error {
) )
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: gui.getBranchesView(),
returnFocusOnClose: true, title: gui.Tr.SLocalize("RebasingTitle"),
title: gui.Tr.SLocalize("RebasingTitle"), prompt: prompt,
prompt: prompt,
handleConfirm: func() error { handleConfirm: func() error {
err := gui.GitCommand.RebaseBranch(selectedBranchName) err := gui.GitCommand.RebaseBranch(selectedBranchName)
return gui.handleGenericMergeCommandResult(err) 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) // way to get it to show up in the reflog)
promptForNewName := func() error { 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 { if err := gui.GitCommand.RenameBranch(branch.Name, newBranchName); err != nil {
return gui.surfaceError(err) return gui.surfaceError(err)
} }
@ -445,11 +438,10 @@ func (gui *Gui) handleRenameBranch(g *gocui.Gui, v *gocui.View) error {
} }
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: v,
returnFocusOnClose: true, title: gui.Tr.SLocalize("renameBranch"),
title: gui.Tr.SLocalize("renameBranch"), prompt: gui.Tr.SLocalize("RenameBranchWarning"),
prompt: gui.Tr.SLocalize("RenameBranchWarning"), handleConfirm: promptForNewName,
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 { if err := gui.GitCommand.NewBranch(response, item.ID()); err != nil {
return err return err
} }

View File

@ -146,10 +146,8 @@ func (gui *Gui) HandlePasteCommits() error {
} }
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: gui.getCommitsView(), title: gui.Tr.SLocalize("CherryPick"),
returnFocusOnClose: true, prompt: gui.Tr.SLocalize("SureCherryPick"),
title: gui.Tr.SLocalize("CherryPick"),
prompt: gui.Tr.SLocalize("SureCherryPick"),
handleConfirm: func() error { handleConfirm: func() error {
return gui.WithWaitingStatus(gui.Tr.SLocalize("CherryPickingStatus"), func() error { return gui.WithWaitingStatus(gui.Tr.SLocalize("CherryPickingStatus"), func() error {
err := gui.GitCommand.CherryPickCommits(gui.State.Modes.CherryPicking.CherryPickedCommits) err := gui.GitCommand.CherryPickCommits(gui.State.Modes.CherryPicking.CherryPickedCommits)

View File

@ -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 fileName := gui.State.CommitFiles[gui.State.Panels.CommitFiles.SelectedLineIdx].Name
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: v, title: gui.Tr.SLocalize("DiscardFileChangesTitle"),
returnFocusOnClose: true, prompt: gui.Tr.SLocalize("DiscardFileChangesPrompt"),
title: gui.Tr.SLocalize("DiscardFileChangesTitle"),
prompt: gui.Tr.SLocalize("DiscardFileChangesPrompt"),
handleConfirm: func() error { handleConfirm: func() error {
return gui.WithWaitingStatus(gui.Tr.SLocalize("RebasingStatus"), 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 { 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 { if gui.GitCommand.PatchManager.Active() && gui.GitCommand.PatchManager.To != commitFile.Parent {
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: v, title: gui.Tr.SLocalize("DiscardPatch"),
returnFocusOnClose: true, prompt: gui.Tr.SLocalize("DiscardPatchConfirm"),
title: gui.Tr.SLocalize("DiscardPatch"),
prompt: gui.Tr.SLocalize("DiscardPatchConfirm"),
handleConfirm: func() error { handleConfirm: func() error {
gui.GitCommand.PatchManager.Reset() gui.GitCommand.PatchManager.Reset()
return toggleTheFile() return toggleTheFile()
@ -189,10 +185,8 @@ func (gui *Gui) enterCommitFile(selectedLineIdx int) error {
if gui.GitCommand.PatchManager.Active() && gui.GitCommand.PatchManager.To != commitFile.Parent { if gui.GitCommand.PatchManager.Active() && gui.GitCommand.PatchManager.To != commitFile.Parent {
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: gui.getCommitFilesView(), title: gui.Tr.SLocalize("DiscardPatch"),
returnFocusOnClose: false, prompt: gui.Tr.SLocalize("DiscardPatchConfirm"),
title: gui.Tr.SLocalize("DiscardPatch"),
prompt: gui.Tr.SLocalize("DiscardPatchConfirm"),
handleConfirm: func() error { handleConfirm: func() error {
gui.GitCommand.PatchManager.Reset() gui.GitCommand.PatchManager.Reset()
return enterTheFile(selectedLineIdx) return enterTheFile(selectedLineIdx)

View File

@ -135,10 +135,8 @@ func (gui *Gui) handleCommitSquashDown(g *gocui.Gui, v *gocui.View) error {
} }
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: v, title: gui.Tr.SLocalize("Squash"),
returnFocusOnClose: true, prompt: gui.Tr.SLocalize("SureSquashThisCommit"),
title: gui.Tr.SLocalize("Squash"),
prompt: gui.Tr.SLocalize("SureSquashThisCommit"),
handleConfirm: func() error { handleConfirm: func() error {
return gui.WithWaitingStatus(gui.Tr.SLocalize("SquashingStatus"), func() error { return gui.WithWaitingStatus(gui.Tr.SLocalize("SquashingStatus"), func() error {
err := gui.GitCommand.InteractiveRebase(gui.State.Commits, gui.State.Panels.Commits.SelectedLineIdx, "squash") 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{ return gui.ask(askOpts{
returnToView: v, title: gui.Tr.SLocalize("Fixup"),
returnFocusOnClose: true, prompt: gui.Tr.SLocalize("SureFixupThisCommit"),
title: gui.Tr.SLocalize("Fixup"),
prompt: gui.Tr.SLocalize("SureFixupThisCommit"),
handleConfirm: func() error { handleConfirm: func() error {
return gui.WithWaitingStatus(gui.Tr.SLocalize("FixingStatus"), func() error { return gui.WithWaitingStatus(gui.Tr.SLocalize("FixingStatus"), func() error {
err := gui.GitCommand.InteractiveRebase(gui.State.Commits, gui.State.Panels.Commits.SelectedLineIdx, "fixup") 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.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 { if err := gui.GitCommand.RenameCommit(response); err != nil {
return gui.surfaceError(err) return gui.surfaceError(err)
} }
@ -279,10 +275,8 @@ func (gui *Gui) handleCommitDelete(g *gocui.Gui, v *gocui.View) error {
} }
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: v, title: gui.Tr.SLocalize("DeleteCommitTitle"),
returnFocusOnClose: true, prompt: gui.Tr.SLocalize("DeleteCommitPrompt"),
title: gui.Tr.SLocalize("DeleteCommitTitle"),
prompt: gui.Tr.SLocalize("DeleteCommitPrompt"),
handleConfirm: func() error { handleConfirm: func() error {
return gui.WithWaitingStatus(gui.Tr.SLocalize("DeletingStatus"), func() error { return gui.WithWaitingStatus(gui.Tr.SLocalize("DeletingStatus"), func() error {
err := gui.GitCommand.InteractiveRebase(gui.State.Commits, gui.State.Panels.Commits.SelectedLineIdx, "drop") 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{ return gui.ask(askOpts{
returnToView: v, title: gui.Tr.SLocalize("AmendCommitTitle"),
returnFocusOnClose: true, prompt: gui.Tr.SLocalize("AmendCommitPrompt"),
title: gui.Tr.SLocalize("AmendCommitTitle"),
prompt: gui.Tr.SLocalize("AmendCommitPrompt"),
handleConfirm: func() error { handleConfirm: func() error {
return gui.WithWaitingStatus(gui.Tr.SLocalize("AmendingStatus"), func() error { return gui.WithWaitingStatus(gui.Tr.SLocalize("AmendingStatus"), func() error {
err := gui.GitCommand.AmendTo(gui.State.Commits[gui.State.Panels.Commits.SelectedLineIdx].Sha) 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{ return gui.ask(askOpts{
returnToView: v, title: gui.Tr.SLocalize("CreateFixupCommit"),
returnFocusOnClose: true,
title: gui.Tr.SLocalize("CreateFixupCommit"),
prompt: gui.Tr.TemplateLocalize( prompt: gui.Tr.TemplateLocalize(
"SureCreateFixupCommit", "SureCreateFixupCommit",
Teml{ Teml{
@ -477,9 +467,7 @@ func (gui *Gui) handleSquashAllAboveFixupCommits(g *gocui.Gui, v *gocui.View) er
} }
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: v, title: gui.Tr.SLocalize("SquashAboveCommits"),
returnFocusOnClose: true,
title: gui.Tr.SLocalize("SquashAboveCommits"),
prompt: gui.Tr.TemplateLocalize( prompt: gui.Tr.TemplateLocalize(
"SureSquashAboveCommits", "SureSquashAboveCommits",
Teml{ Teml{
@ -508,7 +496,7 @@ func (gui *Gui) handleTagCommit(g *gocui.Gui, v *gocui.View) error {
} }
func (gui *Gui) handleCreateLightweightTag(commitSha string) 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 { if err := gui.GitCommand.CreateLightweightTag(response, commitSha); err != nil {
return gui.surfaceError(err) return gui.surfaceError(err)
} }
@ -523,10 +511,8 @@ func (gui *Gui) handleCheckoutCommit(g *gocui.Gui, v *gocui.View) error {
} }
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: gui.getCommitsView(), title: gui.Tr.SLocalize("checkoutCommit"),
returnFocusOnClose: true, prompt: gui.Tr.SLocalize("SureCheckoutThisCommit"),
title: gui.Tr.SLocalize("checkoutCommit"),
prompt: gui.Tr.SLocalize("SureCheckoutThisCommit"),
handleConfirm: func() error { handleConfirm: func() error {
return gui.handleCheckoutRef(commit.Sha, handleCheckoutRefOptions{}) return gui.handleCheckoutRef(commit.Sha, handleCheckoutRefOptions{})
}, },

View File

@ -16,7 +16,6 @@ import (
) )
type createPopupPanelOpts struct { type createPopupPanelOpts struct {
returnToView *gocui.View
hasLoader bool hasLoader bool
returnFocusOnClose bool returnFocusOnClose bool
editable bool editable bool
@ -28,7 +27,6 @@ type createPopupPanelOpts struct {
} }
type askOpts struct { type askOpts struct {
returnToView *gocui.View
returnFocusOnClose bool returnFocusOnClose bool
title string title string
prompt string prompt string
@ -38,30 +36,25 @@ type askOpts struct {
func (gui *Gui) createLoaderPanel(currentView *gocui.View, prompt string) error { func (gui *Gui) createLoaderPanel(currentView *gocui.View, prompt string) error {
return gui.createPopupPanel(createPopupPanelOpts{ return gui.createPopupPanel(createPopupPanelOpts{
returnToView: currentView, prompt: prompt,
prompt: prompt, hasLoader: true,
hasLoader: true,
returnFocusOnClose: true,
}) })
} }
func (gui *Gui) ask(opts askOpts) error { func (gui *Gui) ask(opts askOpts) error {
return gui.createPopupPanel(createPopupPanelOpts{ return gui.createPopupPanel(createPopupPanelOpts{
returnToView: opts.returnToView, title: opts.title,
title: opts.title, prompt: opts.prompt,
prompt: opts.prompt,
returnFocusOnClose: opts.returnFocusOnClose, handleConfirm: opts.handleConfirm,
handleConfirm: opts.handleConfirm, handleClose: opts.handleClose,
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{ return gui.createPopupPanel(createPopupPanelOpts{
returnToView: currentView,
title: title, title: title,
prompt: initialContent, prompt: initialContent,
returnFocusOnClose: true,
editable: true, editable: true,
handleConfirmPrompt: handleConfirm, handleConfirmPrompt: handleConfirm,
}) })
@ -146,7 +139,7 @@ func (gui *Gui) getConfirmationPanelDimensions(wrap bool, prompt string) (int, i
height/2 + panelHeight/2 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) x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(true, prompt)
confirmationView, err := gui.g.SetView("confirmation", x0, y0, x1, y1, 0) confirmationView, err := gui.g.SetView("confirmation", x0, y0, x1, y1, 0)
if err != nil { if err != nil {
@ -175,7 +168,7 @@ func (gui *Gui) createPopupPanel(opts createPopupPanelOpts) error {
gui.Log.Error(err) 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 { if err != nil {
return err return err
} }
@ -232,10 +225,8 @@ func (gui *Gui) createErrorPanel(message string) error {
} }
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: gui.g.CurrentView(), title: gui.Tr.SLocalize("Error"),
title: gui.Tr.SLocalize("Error"), prompt: coloredMessage,
prompt: coloredMessage,
returnFocusOnClose: true,
}) })
} }

View File

@ -127,7 +127,7 @@ func (gui *Gui) handleCreateDiffingMenuPanel(g *gocui.Gui, v *gocui.View) error
{ {
displayString: gui.Tr.SLocalize("enterRefToDiff"), displayString: gui.Tr.SLocalize("enterRefToDiff"),
onPress: func() error { 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) gui.State.Modes.Diffing.Ref = strings.TrimSpace(response)
return gui.refreshSidePanels(refreshOptions{mode: ASYNC}) return gui.refreshSidePanels(refreshOptions{mode: ASYNC})
}) })

View File

@ -232,10 +232,8 @@ func (gui *Gui) handleIgnoreFile(g *gocui.Gui, v *gocui.View) error {
if file.Tracked { if file.Tracked {
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: gui.g.CurrentView(), title: gui.Tr.SLocalize("IgnoreTracked"),
returnFocusOnClose: true, prompt: gui.Tr.SLocalize("IgnoreTrackedPrompt"),
title: gui.Tr.SLocalize("IgnoreTracked"),
prompt: gui.Tr.SLocalize("IgnoreTrackedPrompt"),
handleConfirm: func() error { handleConfirm: func() error {
if err := gui.GitCommand.Ignore(file.Name); err != nil { if err := gui.GitCommand.Ignore(file.Name); err != nil {
return err return err
@ -304,10 +302,8 @@ func (gui *Gui) handleCommitPress() error {
func (gui *Gui) promptToStageAllAndRetry(retry func() error) error { func (gui *Gui) promptToStageAllAndRetry(retry func() error) error {
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: gui.getFilesView(), title: gui.Tr.SLocalize("NoFilesStagedTitle"),
returnFocusOnClose: true, prompt: gui.Tr.SLocalize("NoFilesStagedPrompt"),
title: gui.Tr.SLocalize("NoFilesStagedTitle"),
prompt: gui.Tr.SLocalize("NoFilesStagedPrompt"),
handleConfirm: func() error { handleConfirm: func() error {
if err := gui.GitCommand.StageAll(); err != nil { if err := gui.GitCommand.StageAll(); err != nil {
return gui.surfaceError(err) return gui.surfaceError(err)
@ -333,10 +329,8 @@ func (gui *Gui) handleAmendCommitPress() error {
} }
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: gui.getFilesView(), title: strings.Title(gui.Tr.SLocalize("AmendLastCommit")),
returnFocusOnClose: true, prompt: gui.Tr.SLocalize("SureToAmend"),
title: strings.Title(gui.Tr.SLocalize("AmendLastCommit")),
prompt: gui.Tr.SLocalize("SureToAmend"),
handleConfirm: func() error { handleConfirm: func() error {
ok, err := gui.runSyncOrAsyncCommand(gui.GitCommand.AmendHead()) ok, err := gui.runSyncOrAsyncCommand(gui.GitCommand.AmendHead())
if err != nil { 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 { if err := gui.GitCommand.SetUpstreamBranch(upstream); err != nil {
errorMessage := err.Error() errorMessage := err.Error()
if strings.Contains(errorMessage, "does not exist") { 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) err := gui.GitCommand.Push(branchName, force, upstream, args, gui.promptUserForCredential)
if err != nil && !force && strings.Contains(err.Error(), "Updates were rejected") { if err != nil && !force && strings.Contains(err.Error(), "Updates were rejected") {
gui.ask(askOpts{ gui.ask(askOpts{
returnToView: v, title: gui.Tr.SLocalize("ForcePush"),
returnFocusOnClose: true, prompt: gui.Tr.SLocalize("ForcePushPrompt"),
title: gui.Tr.SLocalize("ForcePush"),
prompt: gui.Tr.SLocalize("ForcePushPrompt"),
handleConfirm: func() error { handleConfirm: func() error {
return gui.pushWithForceFlag(v, true, upstream, args) 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 { if gui.GitCommand.PushToCurrent {
return gui.pushWithForceFlag(v, false, "", "--set-upstream") return gui.pushWithForceFlag(v, false, "", "--set-upstream")
} else { } 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, "") 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{ return gui.ask(askOpts{
returnToView: v, title: gui.Tr.SLocalize("ForcePush"),
returnFocusOnClose: true, prompt: gui.Tr.SLocalize("ForcePushPrompt"),
title: gui.Tr.SLocalize("ForcePush"),
prompt: gui.Tr.SLocalize("ForcePushPrompt"),
handleConfirm: func() error { handleConfirm: func() error {
return gui.pushWithForceFlag(v, true, "", "") 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 { 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) gui.SubProcess = gui.OSCommand.RunCustomCommand(command)
return gui.Errors.ErrSubProcess return gui.Errors.ErrSubProcess
}) })

View File

@ -3,10 +3,8 @@ package gui
func (gui *Gui) validateNotInFilterMode() (bool, error) { func (gui *Gui) validateNotInFilterMode() (bool, error) {
if gui.State.Modes.Filtering.Active() { if gui.State.Modes.Filtering.Active() {
err := gui.ask(askOpts{ err := gui.ask(askOpts{
returnToView: gui.g.CurrentView(), title: gui.Tr.SLocalize("MustExitFilterModeTitle"),
returnFocusOnClose: true, prompt: gui.Tr.SLocalize("MustExitFilterModePrompt"),
title: gui.Tr.SLocalize("MustExitFilterModeTitle"),
prompt: gui.Tr.SLocalize("MustExitFilterModePrompt"),
handleConfirm: func() error { handleConfirm: func() error {
return gui.exitFilterMode() return gui.exitFilterMode()
}, },

View File

@ -41,7 +41,7 @@ func (gui *Gui) handleCreateFilteringMenuPanel(g *gocui.Gui, v *gocui.View) erro
menuItems = append(menuItems, &menuItem{ menuItems = append(menuItems, &menuItem{
displayString: gui.Tr.SLocalize("filterPathOption"), displayString: gui.Tr.SLocalize("filterPathOption"),
onPress: func() error { 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) gui.State.Modes.Filtering.Path = strings.TrimSpace(response)
return gui.Errors.ErrRestart return gui.Errors.ErrRestart
}) })

View File

@ -51,7 +51,7 @@ func (gui *Gui) handleCreateGitFlowMenu(g *gocui.Gui, v *gocui.View) error {
startHandler := func(branchType string) func() error { startHandler := func(branchType string) func() error {
return func() error { return func() error {
title := gui.Tr.TemplateLocalize("NewBranchNamePrompt", map[string]interface{}{"branchType": branchType}) 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) subProcess := gui.OSCommand.PrepareSubProcess("git", "flow", branchType, "start", name)
gui.SubProcess = subProcess gui.SubProcess = subProcess
return gui.Errors.ErrSubProcess return gui.Errors.ErrSubProcess

View File

@ -555,12 +555,10 @@ func (gui *Gui) showIntroPopupMessage(done chan struct{}) error {
} }
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: nil, title: "",
returnFocusOnClose: true, prompt: gui.Tr.SLocalize("IntroPopupMessage"),
title: "", handleConfirm: onConfirm,
prompt: gui.Tr.SLocalize("IntroPopupMessage"), handleClose: onConfirm,
handleConfirm: onConfirm,
handleClose: onConfirm,
}) })
} }
@ -588,10 +586,8 @@ func (gui *Gui) startBackgroundFetch() {
err := gui.fetch(false) err := gui.fetch(false)
if err != nil && strings.Contains(err.Error(), "exit status 128") && isNew { if err != nil && strings.Contains(err.Error(), "exit status 128") && isNew {
_ = gui.ask(askOpts{ _ = gui.ask(askOpts{
returnToView: gui.g.CurrentView(), title: gui.Tr.SLocalize("NoAutomaticGitFetchTitle"),
returnFocusOnClose: true, prompt: gui.Tr.SLocalize("NoAutomaticGitFetchBody"),
title: gui.Tr.SLocalize("NoAutomaticGitFetchTitle"),
prompt: gui.Tr.SLocalize("NoAutomaticGitFetchBody"),
}) })
} else { } else {
gui.goEvery(time.Second*60, gui.stopChan, func() error { gui.goEvery(time.Second*60, gui.stopChan, func() error {

View File

@ -341,10 +341,8 @@ func (gui *Gui) promptToContinue() error {
gui.takeOverScrolling() gui.takeOverScrolling()
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: gui.getFilesView(), title: "continue",
returnFocusOnClose: true, prompt: gui.Tr.SLocalize("ConflictsResolved"),
title: "continue",
prompt: gui.Tr.SLocalize("ConflictsResolved"),
handleConfirm: func() error { handleConfirm: func() error {
return gui.genericMergeCommand("continue") return gui.genericMergeCommand("continue")
}, },

View File

@ -138,10 +138,8 @@ func (gui *Gui) handlePullPatchIntoWorkingTree() error {
if len(gui.trackedFiles()) > 0 { if len(gui.trackedFiles()) > 0 {
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: gui.g.CurrentView(), title: gui.Tr.SLocalize("MustStashTitle"),
returnFocusOnClose: true, prompt: gui.Tr.SLocalize("MustStashWarning"),
title: gui.Tr.SLocalize("MustStashTitle"),
prompt: gui.Tr.SLocalize("MustStashWarning"),
handleConfirm: func() error { handleConfirm: func() error {
return pull(true) return pull(true)
}, },

View File

@ -61,10 +61,8 @@ func (gui *Gui) quit() error {
if gui.Config.GetUserConfig().GetBool("confirmOnQuit") { if gui.Config.GetUserConfig().GetBool("confirmOnQuit") {
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: gui.g.CurrentView(), title: "",
returnFocusOnClose: true, prompt: gui.Tr.SLocalize("ConfirmQuit"),
title: "",
prompt: gui.Tr.SLocalize("ConfirmQuit"),
handleConfirm: func() error { handleConfirm: func() error {
return gocui.ErrQuit return gocui.ErrQuit
}, },

View File

@ -77,10 +77,8 @@ func (gui *Gui) handleGenericMergeCommandResult(result error) error {
return nil return nil
} else if strings.Contains(result.Error(), "When you have resolved this problem") || strings.Contains(result.Error(), "fix conflicts") || strings.Contains(result.Error(), "Resolve all conflicts manually") { } else if strings.Contains(result.Error(), "When you have resolved this problem") || strings.Contains(result.Error(), "fix conflicts") || strings.Contains(result.Error(), "Resolve all conflicts manually") {
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: gui.getFilesView(), title: gui.Tr.SLocalize("FoundConflictsTitle"),
returnFocusOnClose: true, prompt: gui.Tr.SLocalize("FoundConflicts"),
title: gui.Tr.SLocalize("FoundConflictsTitle"),
prompt: gui.Tr.SLocalize("FoundConflicts"),
handleConfirm: func() error { handleConfirm: func() error {
return nil return nil
}, },

View File

@ -90,10 +90,8 @@ func (gui *Gui) handleCheckoutReflogCommit(g *gocui.Gui, v *gocui.View) error {
} }
err := gui.ask(askOpts{ err := gui.ask(askOpts{
returnToView: gui.getCommitsView(), title: gui.Tr.SLocalize("checkoutCommit"),
returnFocusOnClose: true, prompt: gui.Tr.SLocalize("SureCheckoutThisCommit"),
title: gui.Tr.SLocalize("checkoutCommit"),
prompt: gui.Tr.SLocalize("SureCheckoutThisCommit"),
handleConfirm: func() error { handleConfirm: func() error {
return gui.handleCheckoutRef(commit.Sha, handleCheckoutRefOptions{}) return gui.handleCheckoutRef(commit.Sha, handleCheckoutRefOptions{})
}, },

View File

@ -66,10 +66,8 @@ func (gui *Gui) handleDeleteRemoteBranch(g *gocui.Gui, v *gocui.View) error {
message := fmt.Sprintf("%s '%s'?", gui.Tr.SLocalize("DeleteRemoteBranchMessage"), remoteBranch.FullName()) message := fmt.Sprintf("%s '%s'?", gui.Tr.SLocalize("DeleteRemoteBranchMessage"), remoteBranch.FullName())
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: v, title: gui.Tr.SLocalize("DeleteRemoteBranch"),
returnFocusOnClose: true, prompt: message,
title: gui.Tr.SLocalize("DeleteRemoteBranch"),
prompt: message,
handleConfirm: func() error { handleConfirm: func() error {
return gui.WithWaitingStatus(gui.Tr.SLocalize("DeletingStatus"), func() error { return gui.WithWaitingStatus(gui.Tr.SLocalize("DeletingStatus"), func() error {
if err := gui.GitCommand.DeleteRemoteBranch(remoteBranch.RemoteName, remoteBranch.Name); err != nil { if err := gui.GitCommand.DeleteRemoteBranch(remoteBranch.RemoteName, remoteBranch.Name); err != nil {
@ -100,10 +98,8 @@ func (gui *Gui) handleSetBranchUpstream(g *gocui.Gui, v *gocui.View) error {
) )
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: v, title: gui.Tr.SLocalize("SetUpstreamTitle"),
returnFocusOnClose: true, prompt: message,
title: gui.Tr.SLocalize("SetUpstreamTitle"),
prompt: message,
handleConfirm: func() error { handleConfirm: func() error {
if err := gui.GitCommand.SetBranchUpstream(selectedBranch.RemoteName, selectedBranch.Name, checkedOutBranch.Name); err != nil { if err := gui.GitCommand.SetBranchUpstream(selectedBranch.RemoteName, selectedBranch.Name, checkedOutBranch.Name); err != nil {
return err return err

View File

@ -80,9 +80,8 @@ func (gui *Gui) handleRemoteEnter() error {
} }
func (gui *Gui) handleAddRemote(g *gocui.Gui, v *gocui.View) error { func (gui *Gui) handleAddRemote(g *gocui.Gui, v *gocui.View) error {
branchesView := gui.getBranchesView() return gui.prompt(gui.Tr.SLocalize("newRemoteName"), "", func(remoteName string) error {
return gui.prompt(branchesView, gui.Tr.SLocalize("newRemoteName"), "", func(remoteName string) error { return gui.prompt(gui.Tr.SLocalize("newRemoteUrl"), "", func(remoteUrl string) error {
return gui.prompt(branchesView, gui.Tr.SLocalize("newRemoteUrl"), "", func(remoteUrl string) error {
if err := gui.GitCommand.AddRemote(remoteName, remoteUrl); err != nil { if err := gui.GitCommand.AddRemote(remoteName, remoteUrl); err != nil {
return err return err
} }
@ -98,10 +97,8 @@ func (gui *Gui) handleRemoveRemote(g *gocui.Gui, v *gocui.View) error {
} }
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: v, title: gui.Tr.SLocalize("removeRemote"),
returnFocusOnClose: true, prompt: gui.Tr.SLocalize("removeRemotePrompt") + " '" + remote.Name + "'?",
title: gui.Tr.SLocalize("removeRemote"),
prompt: gui.Tr.SLocalize("removeRemotePrompt") + " '" + remote.Name + "'?",
handleConfirm: func() error { handleConfirm: func() error {
if err := gui.GitCommand.RemoveRemote(remote.Name); err != nil { if err := gui.GitCommand.RemoveRemote(remote.Name); err != nil {
return err return err
@ -113,7 +110,6 @@ func (gui *Gui) handleRemoveRemote(g *gocui.Gui, v *gocui.View) error {
} }
func (gui *Gui) handleEditRemote(g *gocui.Gui, v *gocui.View) error { func (gui *Gui) handleEditRemote(g *gocui.Gui, v *gocui.View) error {
branchesView := gui.getBranchesView()
remote := gui.getSelectedRemote() remote := gui.getSelectedRemote()
if remote == nil { if remote == nil {
return nil return nil
@ -126,7 +122,7 @@ func (gui *Gui) handleEditRemote(g *gocui.Gui, v *gocui.View) error {
}, },
) )
return gui.prompt(branchesView, editNameMessage, "", func(updatedRemoteName string) error { return gui.prompt(editNameMessage, "", func(updatedRemoteName string) error {
if updatedRemoteName != remote.Name { if updatedRemoteName != remote.Name {
if err := gui.GitCommand.RenameRemote(remote.Name, updatedRemoteName); err != nil { if err := gui.GitCommand.RenameRemote(remote.Name, updatedRemoteName); err != nil {
return gui.surfaceError(err) return gui.surfaceError(err)
@ -140,7 +136,7 @@ func (gui *Gui) handleEditRemote(g *gocui.Gui, v *gocui.View) error {
}, },
) )
return gui.prompt(branchesView, editUrlMessage, "", func(updatedRemoteUrl string) error { return gui.prompt(editUrlMessage, "", func(updatedRemoteUrl string) error {
if err := gui.GitCommand.UpdateRemoteUrl(updatedRemoteName, updatedRemoteUrl); err != nil { if err := gui.GitCommand.UpdateRemoteUrl(updatedRemoteName, updatedRemoteUrl); err != nil {
return gui.surfaceError(err) return gui.surfaceError(err)
} }

View File

@ -105,10 +105,8 @@ func (gui *Gui) handleResetSelection(g *gocui.Gui, v *gocui.View) error {
if !gui.Config.GetUserConfig().GetBool("gui.skipUnstageLineWarning") { if !gui.Config.GetUserConfig().GetBool("gui.skipUnstageLineWarning") {
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: gui.getMainView(), title: gui.Tr.SLocalize("UnstageLinesTitle"),
returnFocusOnClose: false, prompt: gui.Tr.SLocalize("UnstageLinesPrompt"),
title: gui.Tr.SLocalize("UnstageLinesTitle"),
prompt: gui.Tr.SLocalize("UnstageLinesPrompt"),
handleConfirm: func() error { handleConfirm: func() error {
return gui.applySelection(true) return gui.applySelection(true)
}, },

View File

@ -56,10 +56,8 @@ func (gui *Gui) handleStashApply(g *gocui.Gui, v *gocui.View) error {
} }
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: v, title: gui.Tr.SLocalize("StashApply"),
returnFocusOnClose: true, prompt: gui.Tr.SLocalize("SureApplyStashEntry"),
title: gui.Tr.SLocalize("StashApply"),
prompt: gui.Tr.SLocalize("SureApplyStashEntry"),
handleConfirm: func() error { handleConfirm: func() error {
return apply() return apply()
}, },
@ -78,10 +76,8 @@ func (gui *Gui) handleStashPop(g *gocui.Gui, v *gocui.View) error {
} }
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: v, title: gui.Tr.SLocalize("StashPop"),
returnFocusOnClose: true, prompt: gui.Tr.SLocalize("SurePopStashEntry"),
title: gui.Tr.SLocalize("StashPop"),
prompt: gui.Tr.SLocalize("SurePopStashEntry"),
handleConfirm: func() error { handleConfirm: func() error {
return pop() return pop()
}, },
@ -90,10 +86,8 @@ func (gui *Gui) handleStashPop(g *gocui.Gui, v *gocui.View) error {
func (gui *Gui) handleStashDrop(g *gocui.Gui, v *gocui.View) error { func (gui *Gui) handleStashDrop(g *gocui.Gui, v *gocui.View) error {
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: v, title: gui.Tr.SLocalize("StashDrop"),
returnFocusOnClose: true, prompt: gui.Tr.SLocalize("SureDropStashEntry"),
title: gui.Tr.SLocalize("StashDrop"),
prompt: gui.Tr.SLocalize("SureDropStashEntry"),
handleConfirm: func() error { handleConfirm: func() error {
return gui.stashDo("drop") return gui.stashDo("drop")
}, },
@ -121,7 +115,7 @@ func (gui *Gui) handleStashSave(stashFunc func(message string) error) error {
if len(gui.trackedFiles()) == 0 && len(gui.stagedFiles()) == 0 { if len(gui.trackedFiles()) == 0 && len(gui.stagedFiles()) == 0 {
return gui.createErrorPanel(gui.Tr.SLocalize("NoTrackedStagedFilesStash")) return gui.createErrorPanel(gui.Tr.SLocalize("NoTrackedStagedFilesStash"))
} }
return gui.prompt(gui.getFilesView(), gui.Tr.SLocalize("StashChanges"), "", func(stashComment string) error { return gui.prompt(gui.Tr.SLocalize("StashChanges"), "", func(stashComment string) error {
if err := stashFunc(stashComment); err != nil { if err := stashFunc(stashComment); err != nil {
return gui.surfaceError(err) return gui.surfaceError(err)
} }

View File

@ -45,10 +45,8 @@ func (gui *Gui) handleCheckoutSubCommit(g *gocui.Gui, v *gocui.View) error {
} }
err := gui.ask(askOpts{ err := gui.ask(askOpts{
returnToView: gui.getCommitsView(), title: gui.Tr.SLocalize("checkoutCommit"),
returnFocusOnClose: true, prompt: gui.Tr.SLocalize("SureCheckoutThisCommit"),
title: gui.Tr.SLocalize("checkoutCommit"),
prompt: gui.Tr.SLocalize("SureCheckoutThisCommit"),
handleConfirm: func() error { handleConfirm: func() error {
return gui.handleCheckoutRef(commit.Sha, handleCheckoutRefOptions{}) return gui.handleCheckoutRef(commit.Sha, handleCheckoutRefOptions{})
}, },

View File

@ -72,10 +72,8 @@ func (gui *Gui) handleDeleteTag(g *gocui.Gui, v *gocui.View) error {
) )
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: v, title: gui.Tr.SLocalize("DeleteTagTitle"),
returnFocusOnClose: true, prompt: prompt,
title: gui.Tr.SLocalize("DeleteTagTitle"),
prompt: prompt,
handleConfirm: func() error { handleConfirm: func() error {
if err := gui.GitCommand.DeleteTag(tag.Name); err != nil { if err := gui.GitCommand.DeleteTag(tag.Name); err != nil {
return gui.surfaceError(err) return gui.surfaceError(err)
@ -98,7 +96,7 @@ func (gui *Gui) handlePushTag(g *gocui.Gui, v *gocui.View) error {
}, },
) )
return gui.prompt(v, title, "origin", func(response string) error { return gui.prompt(title, "origin", func(response string) error {
if err := gui.GitCommand.PushTag(response, tag.Name); err != nil { if err := gui.GitCommand.PushTag(response, tag.Name); err != nil {
return gui.surfaceError(err) return gui.surfaceError(err)
} }
@ -107,7 +105,7 @@ func (gui *Gui) handlePushTag(g *gocui.Gui, v *gocui.View) error {
} }
func (gui *Gui) handleCreateTag(g *gocui.Gui, v *gocui.View) error { func (gui *Gui) handleCreateTag(g *gocui.Gui, v *gocui.View) error {
return gui.prompt(v, gui.Tr.SLocalize("CreateTagTitle"), "", func(tagName string) error { return gui.prompt(gui.Tr.SLocalize("CreateTagTitle"), "", func(tagName string) error {
// leaving commit SHA blank so that we're just creating the tag for the current commit // leaving commit SHA blank so that we're just creating the tag for the current commit
if err := gui.GitCommand.CreateLightweightTag(tagName, ""); err != nil { if err := gui.GitCommand.CreateLightweightTag(tagName, ""); err != nil {
return gui.surfaceError(err) return gui.surfaceError(err)

View File

@ -167,10 +167,8 @@ func (gui *Gui) handleHardResetWithAutoStash(commitSha string, options handleHar
if dirtyWorkingTree { if dirtyWorkingTree {
// offer to autostash changes // offer to autostash changes
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: gui.getBranchesView(), title: gui.Tr.SLocalize("AutoStashTitle"),
returnFocusOnClose: true, prompt: gui.Tr.SLocalize("AutoStashPrompt"),
title: gui.Tr.SLocalize("AutoStashTitle"),
prompt: gui.Tr.SLocalize("AutoStashPrompt"),
handleConfirm: func() error { handleConfirm: func() error {
return gui.WithWaitingStatus(options.WaitingStatus, func() error { return gui.WithWaitingStatus(options.WaitingStatus, func() error {
if err := gui.GitCommand.StashSave(gui.Tr.SLocalize("StashPrefix") + commitSha); err != nil { if err := gui.GitCommand.StashSave(gui.Tr.SLocalize("StashPrefix") + commitSha); err != nil {

View File

@ -2,14 +2,11 @@ package gui
import "github.com/jesseduffield/gocui" import "github.com/jesseduffield/gocui"
func (gui *Gui) showUpdatePrompt(newVersion string) error {
currentView := gui.g.CurrentView()
func (gui *Gui) showUpdatePrompt(newVersion string) error {
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: currentView, title: "New version available!",
returnFocusOnClose: true, prompt: "Download latest version? (enter/esc)",
title: "New version available!",
prompt: "Download latest version? (enter/esc)",
handleConfirm: func() error { handleConfirm: func() error {
gui.startUpdating(newVersion) gui.startUpdating(newVersion)
return nil return nil
@ -61,10 +58,8 @@ func (gui *Gui) onUpdateFinish(err error) error {
func (gui *Gui) createUpdateQuitConfirmation() error { func (gui *Gui) createUpdateQuitConfirmation() error {
return gui.ask(askOpts{ return gui.ask(askOpts{
returnToView: gui.g.CurrentView(), title: "Currently Updating",
returnFocusOnClose: true, prompt: "An update is in progress. Are you sure you want to quit?",
title: "Currently Updating",
prompt: "An update is in progress. Are you sure you want to quit?",
handleConfirm: func() error { handleConfirm: func() error {
return gocui.ErrQuit return gocui.ErrQuit
}, },