mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 21:05:48 +02:00
use context to return to the correct view
This commit is contained in:
parent
9ca0073cd7
commit
94601b4dc9
24 changed files with 124 additions and 216 deletions
|
@ -115,8 +115,6 @@ 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,
|
||||
handleConfirm: func() error {
|
||||
|
@ -160,8 +158,7 @@ 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"),
|
||||
handleConfirm: func() error {
|
||||
|
@ -195,13 +192,12 @@ 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, "?"),
|
||||
handleConfirm: func() error {
|
||||
|
@ -266,8 +262,7 @@ func (gui *Gui) deleteNamedBranch(selectedBranch *commands.Branch, force bool) e
|
|||
)
|
||||
|
||||
return gui.ask(askOpts{
|
||||
returnToView: gui.getBranchesView(),
|
||||
returnFocusOnClose: true,
|
||||
|
||||
title: title,
|
||||
prompt: message,
|
||||
handleConfirm: func() error {
|
||||
|
@ -304,8 +299,7 @@ func (gui *Gui) mergeBranchIntoCheckedOutBranch(branchName string) error {
|
|||
)
|
||||
|
||||
return gui.ask(askOpts{
|
||||
returnToView: gui.getBranchesView(),
|
||||
returnFocusOnClose: true,
|
||||
|
||||
title: gui.Tr.SLocalize("MergingTitle"),
|
||||
prompt: prompt,
|
||||
handleConfirm: func() error {
|
||||
|
@ -347,8 +341,7 @@ func (gui *Gui) handleRebaseOntoBranch(selectedBranchName string) error {
|
|||
)
|
||||
|
||||
return gui.ask(askOpts{
|
||||
returnToView: gui.getBranchesView(),
|
||||
returnFocusOnClose: true,
|
||||
|
||||
title: gui.Tr.SLocalize("RebasingTitle"),
|
||||
prompt: prompt,
|
||||
handleConfirm: func() error {
|
||||
|
@ -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,8 +438,7 @@ 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,
|
||||
|
@ -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
|
||||
}
|
||||
|
|
|
@ -146,8 +146,6 @@ func (gui *Gui) HandlePasteCommits() error {
|
|||
}
|
||||
|
||||
return gui.ask(askOpts{
|
||||
returnToView: gui.getCommitsView(),
|
||||
returnFocusOnClose: true,
|
||||
title: gui.Tr.SLocalize("CherryPick"),
|
||||
prompt: gui.Tr.SLocalize("SureCherryPick"),
|
||||
handleConfirm: func() error {
|
||||
|
|
|
@ -59,8 +59,6 @@ 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"),
|
||||
handleConfirm: func() error {
|
||||
|
@ -139,8 +137,6 @@ 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"),
|
||||
handleConfirm: func() error {
|
||||
|
@ -189,8 +185,6 @@ 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"),
|
||||
handleConfirm: func() error {
|
||||
|
|
|
@ -135,8 +135,6 @@ 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"),
|
||||
handleConfirm: func() error {
|
||||
|
@ -166,8 +164,6 @@ 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"),
|
||||
handleConfirm: func() error {
|
||||
|
@ -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,8 +275,6 @@ 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"),
|
||||
handleConfirm: func() error {
|
||||
|
@ -371,8 +365,6 @@ 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"),
|
||||
handleConfirm: func() error {
|
||||
|
@ -447,8 +439,6 @@ func (gui *Gui) handleCreateFixupCommit(g *gocui.Gui, v *gocui.View) error {
|
|||
}
|
||||
|
||||
return gui.ask(askOpts{
|
||||
returnToView: v,
|
||||
returnFocusOnClose: true,
|
||||
title: gui.Tr.SLocalize("CreateFixupCommit"),
|
||||
prompt: gui.Tr.TemplateLocalize(
|
||||
"SureCreateFixupCommit",
|
||||
|
@ -477,8 +467,6 @@ func (gui *Gui) handleSquashAllAboveFixupCommits(g *gocui.Gui, v *gocui.View) er
|
|||
}
|
||||
|
||||
return gui.ask(askOpts{
|
||||
returnToView: v,
|
||||
returnFocusOnClose: true,
|
||||
title: gui.Tr.SLocalize("SquashAboveCommits"),
|
||||
prompt: gui.Tr.TemplateLocalize(
|
||||
"SureSquashAboveCommits",
|
||||
|
@ -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,8 +511,6 @@ 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"),
|
||||
handleConfirm: func() error {
|
||||
|
|
|
@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
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,
|
||||
})
|
||||
}
|
||||
|
||||
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,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -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})
|
||||
})
|
||||
|
|
|
@ -232,8 +232,6 @@ 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"),
|
||||
handleConfirm: func() error {
|
||||
|
@ -304,8 +302,6 @@ 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"),
|
||||
handleConfirm: func() error {
|
||||
|
@ -333,8 +329,6 @@ 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"),
|
||||
handleConfirm: func() error {
|
||||
|
@ -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,8 +506,6 @@ 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"),
|
||||
handleConfirm: func() error {
|
||||
|
@ -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,8 +553,6 @@ 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"),
|
||||
handleConfirm: func() error {
|
||||
|
@ -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
|
||||
})
|
||||
|
|
|
@ -3,8 +3,6 @@ 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"),
|
||||
handleConfirm: func() error {
|
||||
|
|
|
@ -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
|
||||
})
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -555,8 +555,6 @@ func (gui *Gui) showIntroPopupMessage(done chan struct{}) error {
|
|||
}
|
||||
|
||||
return gui.ask(askOpts{
|
||||
returnToView: nil,
|
||||
returnFocusOnClose: true,
|
||||
title: "",
|
||||
prompt: gui.Tr.SLocalize("IntroPopupMessage"),
|
||||
handleConfirm: onConfirm,
|
||||
|
@ -588,8 +586,6 @@ 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"),
|
||||
})
|
||||
|
|
|
@ -341,8 +341,6 @@ func (gui *Gui) promptToContinue() error {
|
|||
gui.takeOverScrolling()
|
||||
|
||||
return gui.ask(askOpts{
|
||||
returnToView: gui.getFilesView(),
|
||||
returnFocusOnClose: true,
|
||||
title: "continue",
|
||||
prompt: gui.Tr.SLocalize("ConflictsResolved"),
|
||||
handleConfirm: func() error {
|
||||
|
|
|
@ -138,8 +138,6 @@ 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"),
|
||||
handleConfirm: func() error {
|
||||
|
|
|
@ -61,8 +61,6 @@ 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"),
|
||||
handleConfirm: func() error {
|
||||
|
|
|
@ -77,8 +77,6 @@ func (gui *Gui) handleGenericMergeCommandResult(result error) error {
|
|||
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") {
|
||||
return gui.ask(askOpts{
|
||||
returnToView: gui.getFilesView(),
|
||||
returnFocusOnClose: true,
|
||||
title: gui.Tr.SLocalize("FoundConflictsTitle"),
|
||||
prompt: gui.Tr.SLocalize("FoundConflicts"),
|
||||
handleConfirm: func() error {
|
||||
|
|
|
@ -90,8 +90,6 @@ func (gui *Gui) handleCheckoutReflogCommit(g *gocui.Gui, v *gocui.View) error {
|
|||
}
|
||||
|
||||
err := gui.ask(askOpts{
|
||||
returnToView: gui.getCommitsView(),
|
||||
returnFocusOnClose: true,
|
||||
title: gui.Tr.SLocalize("checkoutCommit"),
|
||||
prompt: gui.Tr.SLocalize("SureCheckoutThisCommit"),
|
||||
handleConfirm: func() error {
|
||||
|
|
|
@ -66,8 +66,6 @@ func (gui *Gui) handleDeleteRemoteBranch(g *gocui.Gui, v *gocui.View) error {
|
|||
message := fmt.Sprintf("%s '%s'?", gui.Tr.SLocalize("DeleteRemoteBranchMessage"), remoteBranch.FullName())
|
||||
|
||||
return gui.ask(askOpts{
|
||||
returnToView: v,
|
||||
returnFocusOnClose: true,
|
||||
title: gui.Tr.SLocalize("DeleteRemoteBranch"),
|
||||
prompt: message,
|
||||
handleConfirm: func() error {
|
||||
|
@ -100,8 +98,6 @@ func (gui *Gui) handleSetBranchUpstream(g *gocui.Gui, v *gocui.View) error {
|
|||
)
|
||||
|
||||
return gui.ask(askOpts{
|
||||
returnToView: v,
|
||||
returnFocusOnClose: true,
|
||||
title: gui.Tr.SLocalize("SetUpstreamTitle"),
|
||||
prompt: message,
|
||||
handleConfirm: func() error {
|
||||
|
|
|
@ -80,9 +80,8 @@ func (gui *Gui) handleRemoteEnter() error {
|
|||
}
|
||||
|
||||
func (gui *Gui) handleAddRemote(g *gocui.Gui, v *gocui.View) error {
|
||||
branchesView := gui.getBranchesView()
|
||||
return gui.prompt(branchesView, gui.Tr.SLocalize("newRemoteName"), "", func(remoteName string) error {
|
||||
return gui.prompt(branchesView, gui.Tr.SLocalize("newRemoteUrl"), "", func(remoteUrl string) error {
|
||||
return gui.prompt(gui.Tr.SLocalize("newRemoteName"), "", func(remoteName string) error {
|
||||
return gui.prompt(gui.Tr.SLocalize("newRemoteUrl"), "", func(remoteUrl string) error {
|
||||
if err := gui.GitCommand.AddRemote(remoteName, remoteUrl); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -98,8 +97,6 @@ func (gui *Gui) handleRemoveRemote(g *gocui.Gui, v *gocui.View) error {
|
|||
}
|
||||
|
||||
return gui.ask(askOpts{
|
||||
returnToView: v,
|
||||
returnFocusOnClose: true,
|
||||
title: gui.Tr.SLocalize("removeRemote"),
|
||||
prompt: gui.Tr.SLocalize("removeRemotePrompt") + " '" + remote.Name + "'?",
|
||||
handleConfirm: func() error {
|
||||
|
@ -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 {
|
||||
branchesView := gui.getBranchesView()
|
||||
remote := gui.getSelectedRemote()
|
||||
if remote == 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 err := gui.GitCommand.RenameRemote(remote.Name, updatedRemoteName); err != nil {
|
||||
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 {
|
||||
return gui.surfaceError(err)
|
||||
}
|
||||
|
|
|
@ -105,8 +105,6 @@ func (gui *Gui) handleResetSelection(g *gocui.Gui, v *gocui.View) error {
|
|||
|
||||
if !gui.Config.GetUserConfig().GetBool("gui.skipUnstageLineWarning") {
|
||||
return gui.ask(askOpts{
|
||||
returnToView: gui.getMainView(),
|
||||
returnFocusOnClose: false,
|
||||
title: gui.Tr.SLocalize("UnstageLinesTitle"),
|
||||
prompt: gui.Tr.SLocalize("UnstageLinesPrompt"),
|
||||
handleConfirm: func() error {
|
||||
|
|
|
@ -56,8 +56,6 @@ func (gui *Gui) handleStashApply(g *gocui.Gui, v *gocui.View) error {
|
|||
}
|
||||
|
||||
return gui.ask(askOpts{
|
||||
returnToView: v,
|
||||
returnFocusOnClose: true,
|
||||
title: gui.Tr.SLocalize("StashApply"),
|
||||
prompt: gui.Tr.SLocalize("SureApplyStashEntry"),
|
||||
handleConfirm: func() error {
|
||||
|
@ -78,8 +76,6 @@ func (gui *Gui) handleStashPop(g *gocui.Gui, v *gocui.View) error {
|
|||
}
|
||||
|
||||
return gui.ask(askOpts{
|
||||
returnToView: v,
|
||||
returnFocusOnClose: true,
|
||||
title: gui.Tr.SLocalize("StashPop"),
|
||||
prompt: gui.Tr.SLocalize("SurePopStashEntry"),
|
||||
handleConfirm: func() error {
|
||||
|
@ -90,8 +86,6 @@ func (gui *Gui) handleStashPop(g *gocui.Gui, v *gocui.View) error {
|
|||
|
||||
func (gui *Gui) handleStashDrop(g *gocui.Gui, v *gocui.View) error {
|
||||
return gui.ask(askOpts{
|
||||
returnToView: v,
|
||||
returnFocusOnClose: true,
|
||||
title: gui.Tr.SLocalize("StashDrop"),
|
||||
prompt: gui.Tr.SLocalize("SureDropStashEntry"),
|
||||
handleConfirm: func() error {
|
||||
|
@ -121,7 +115,7 @@ func (gui *Gui) handleStashSave(stashFunc func(message string) error) error {
|
|||
if len(gui.trackedFiles()) == 0 && len(gui.stagedFiles()) == 0 {
|
||||
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 {
|
||||
return gui.surfaceError(err)
|
||||
}
|
||||
|
|
|
@ -45,8 +45,6 @@ func (gui *Gui) handleCheckoutSubCommit(g *gocui.Gui, v *gocui.View) error {
|
|||
}
|
||||
|
||||
err := gui.ask(askOpts{
|
||||
returnToView: gui.getCommitsView(),
|
||||
returnFocusOnClose: true,
|
||||
title: gui.Tr.SLocalize("checkoutCommit"),
|
||||
prompt: gui.Tr.SLocalize("SureCheckoutThisCommit"),
|
||||
handleConfirm: func() error {
|
||||
|
|
|
@ -72,8 +72,6 @@ func (gui *Gui) handleDeleteTag(g *gocui.Gui, v *gocui.View) error {
|
|||
)
|
||||
|
||||
return gui.ask(askOpts{
|
||||
returnToView: v,
|
||||
returnFocusOnClose: true,
|
||||
title: gui.Tr.SLocalize("DeleteTagTitle"),
|
||||
prompt: prompt,
|
||||
handleConfirm: func() error {
|
||||
|
@ -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 {
|
||||
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 {
|
||||
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
|
||||
if err := gui.GitCommand.CreateLightweightTag(tagName, ""); err != nil {
|
||||
return gui.surfaceError(err)
|
||||
|
|
|
@ -167,8 +167,6 @@ func (gui *Gui) handleHardResetWithAutoStash(commitSha string, options handleHar
|
|||
if dirtyWorkingTree {
|
||||
// offer to autostash changes
|
||||
return gui.ask(askOpts{
|
||||
returnToView: gui.getBranchesView(),
|
||||
returnFocusOnClose: true,
|
||||
title: gui.Tr.SLocalize("AutoStashTitle"),
|
||||
prompt: gui.Tr.SLocalize("AutoStashPrompt"),
|
||||
handleConfirm: func() error {
|
||||
|
|
|
@ -2,12 +2,9 @@ package gui
|
|||
|
||||
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{
|
||||
returnToView: currentView,
|
||||
returnFocusOnClose: true,
|
||||
title: "New version available!",
|
||||
prompt: "Download latest version? (enter/esc)",
|
||||
handleConfirm: func() error {
|
||||
|
@ -61,8 +58,6 @@ func (gui *Gui) onUpdateFinish(err error) error {
|
|||
|
||||
func (gui *Gui) createUpdateQuitConfirmation() error {
|
||||
return gui.ask(askOpts{
|
||||
returnToView: gui.g.CurrentView(),
|
||||
returnFocusOnClose: true,
|
||||
title: "Currently Updating",
|
||||
prompt: "An update is in progress. Are you sure you want to quit?",
|
||||
handleConfirm: func() error {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue