mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-02-09 13:47:11 +02:00
more removing of g
This commit is contained in:
parent
15229bbdab
commit
9b7a6934b3
@ -277,10 +277,10 @@ func (gui *Gui) createNewBranchWithName(newBranchName string) error {
|
||||
}
|
||||
|
||||
func (gui *Gui) handleDeleteBranch(g *gocui.Gui, v *gocui.View) error {
|
||||
return gui.deleteBranch(g, v, false)
|
||||
return gui.deleteBranch(false)
|
||||
}
|
||||
|
||||
func (gui *Gui) deleteBranch(g *gocui.Gui, v *gocui.View, force bool) error {
|
||||
func (gui *Gui) deleteBranch(force bool) error {
|
||||
selectedBranch := gui.getSelectedBranch()
|
||||
if selectedBranch == nil {
|
||||
return nil
|
||||
@ -289,10 +289,10 @@ func (gui *Gui) deleteBranch(g *gocui.Gui, v *gocui.View, force bool) error {
|
||||
if checkedOutBranch.Name == selectedBranch.Name {
|
||||
return gui.createErrorPanel(gui.Tr.SLocalize("CantDeleteCheckOutBranch"))
|
||||
}
|
||||
return gui.deleteNamedBranch(g, v, selectedBranch, force)
|
||||
return gui.deleteNamedBranch(selectedBranch, force)
|
||||
}
|
||||
|
||||
func (gui *Gui) deleteNamedBranch(g *gocui.Gui, v *gocui.View, selectedBranch *commands.Branch, force bool) error {
|
||||
func (gui *Gui) deleteNamedBranch(selectedBranch *commands.Branch, force bool) error {
|
||||
title := gui.Tr.SLocalize("DeleteBranch")
|
||||
var messageID string
|
||||
if force {
|
||||
@ -308,7 +308,7 @@ func (gui *Gui) deleteNamedBranch(g *gocui.Gui, v *gocui.View, selectedBranch *c
|
||||
)
|
||||
|
||||
return gui.ask(askOpts{
|
||||
returnToView: v,
|
||||
returnToView: gui.getBranchesView(),
|
||||
returnFocusOnClose: true,
|
||||
title: title,
|
||||
prompt: message,
|
||||
@ -316,7 +316,7 @@ func (gui *Gui) deleteNamedBranch(g *gocui.Gui, v *gocui.View, selectedBranch *c
|
||||
if err := gui.GitCommand.DeleteBranch(selectedBranch.Name, force); err != nil {
|
||||
errMessage := err.Error()
|
||||
if !force && strings.Contains(errMessage, "is not fully merged") {
|
||||
return gui.deleteNamedBranch(g, v, selectedBranch, true)
|
||||
return gui.deleteNamedBranch(selectedBranch, true)
|
||||
}
|
||||
return gui.createErrorPanel(errMessage)
|
||||
}
|
||||
|
@ -512,7 +512,7 @@ func (gui *Gui) HandlePasteCommits(g *gocui.Gui, v *gocui.View) error {
|
||||
})
|
||||
}
|
||||
|
||||
func (gui *Gui) handleSwitchToCommitFilesPanel(g *gocui.Gui, v *gocui.View) error {
|
||||
func (gui *Gui) handleSwitchToCommitFilesPanel() error {
|
||||
if err := gui.refreshCommitFilesView(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ func (gui *Gui) wrappedConfirmationFunction(function func() error, returnFocusOn
|
||||
}
|
||||
}
|
||||
|
||||
return gui.closeConfirmationPrompt(g, returnFocusOnClose)
|
||||
return gui.closeConfirmationPrompt(returnFocusOnClose)
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,24 +89,24 @@ func (gui *Gui) wrappedPromptConfirmationFunction(function func(string) error, r
|
||||
}
|
||||
}
|
||||
|
||||
return gui.closeConfirmationPrompt(g, returnFocusOnClose)
|
||||
return gui.closeConfirmationPrompt(returnFocusOnClose)
|
||||
}
|
||||
}
|
||||
|
||||
func (gui *Gui) closeConfirmationPrompt(g *gocui.Gui, returnFocusOnClose bool) error {
|
||||
view, err := g.View("confirmation")
|
||||
func (gui *Gui) closeConfirmationPrompt(returnFocusOnClose bool) error {
|
||||
view, err := gui.g.View("confirmation")
|
||||
if err != nil {
|
||||
return nil // if it's already been closed we can just return
|
||||
}
|
||||
view.Editable = false
|
||||
if returnFocusOnClose {
|
||||
if err := gui.returnFocus(g, view); err != nil {
|
||||
if err := gui.returnFocus(view); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
g.DeleteKeybinding("confirmation", gocui.KeyEnter, gocui.ModNone)
|
||||
g.DeleteKeybinding("confirmation", gocui.KeyEsc, gocui.ModNone)
|
||||
return g.DeleteView("confirmation")
|
||||
gui.g.DeleteKeybinding("confirmation", gocui.KeyEnter, gocui.ModNone)
|
||||
gui.g.DeleteKeybinding("confirmation", gocui.KeyEsc, gocui.ModNone)
|
||||
return gui.g.DeleteView("confirmation")
|
||||
}
|
||||
|
||||
func (gui *Gui) getMessageHeight(wrap bool, message string, width int) int {
|
||||
@ -123,8 +123,8 @@ func (gui *Gui) getMessageHeight(wrap bool, message string, width int) int {
|
||||
return lineCount
|
||||
}
|
||||
|
||||
func (gui *Gui) getConfirmationPanelDimensions(g *gocui.Gui, wrap bool, prompt string) (int, int, int, int) {
|
||||
width, height := g.Size()
|
||||
func (gui *Gui) getConfirmationPanelDimensions(wrap bool, prompt string) (int, int, int, int) {
|
||||
width, height := gui.g.Size()
|
||||
// we want a minimum width up to a point, then we do it based on ratio.
|
||||
panelWidth := 4 * width / 7
|
||||
minWidth := 80
|
||||
@ -146,7 +146,7 @@ func (gui *Gui) getConfirmationPanelDimensions(g *gocui.Gui, wrap bool, prompt s
|
||||
}
|
||||
|
||||
func (gui *Gui) prepareConfirmationPanel(currentView *gocui.View, title, prompt string, hasLoader bool) (*gocui.View, error) {
|
||||
x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(gui.g, true, prompt)
|
||||
x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(true, prompt)
|
||||
confirmationView, err := gui.g.SetView("confirmation", x0, y0, x1, y1, 0)
|
||||
if err != nil {
|
||||
if err.Error() != "unknown view" {
|
||||
@ -180,7 +180,7 @@ func (gui *Gui) createPopupPanel(opts createPopupPanelOpts) error {
|
||||
gui.g.Update(func(g *gocui.Gui) error {
|
||||
// delete the existing confirmation panel if it exists
|
||||
if view, _ := g.View("confirmation"); view != nil {
|
||||
if err := gui.closeConfirmationPrompt(g, true); err != nil {
|
||||
if err := gui.closeConfirmationPrompt(true); err != nil {
|
||||
gui.Log.Error(err)
|
||||
}
|
||||
}
|
||||
|
@ -87,6 +87,6 @@ func (gui *Gui) handleCredentialsPopup(cmdErr error) {
|
||||
// we are not logging this error because it may contain a password
|
||||
gui.createErrorPanel(errMessage)
|
||||
} else {
|
||||
_ = gui.closeConfirmationPrompt(gui.g, true)
|
||||
_ = gui.closeConfirmationPrompt(true)
|
||||
}
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ func (gui *Gui) enterFile(forceSecondaryFocused bool, selectedLineIdx int) error
|
||||
return nil
|
||||
}
|
||||
if file.HasInlineMergeConflicts {
|
||||
return gui.handleSwitchToMerge(gui.g, gui.getFilesView())
|
||||
return gui.handleSwitchToMerge()
|
||||
}
|
||||
if file.HasMergeConflicts {
|
||||
return gui.createErrorPanel(gui.Tr.SLocalize("FileStagingRequirements"))
|
||||
@ -178,7 +178,7 @@ func (gui *Gui) enterFile(forceSecondaryFocused bool, selectedLineIdx int) error
|
||||
return gui.refreshStagingPanel(forceSecondaryFocused, selectedLineIdx)
|
||||
}
|
||||
|
||||
func (gui *Gui) handleFilePress(g *gocui.Gui, v *gocui.View) error {
|
||||
func (gui *Gui) handleFilePress() error {
|
||||
file, err := gui.getSelectedFile()
|
||||
if err != nil {
|
||||
if err == gui.Errors.ErrNoFiles {
|
||||
@ -188,7 +188,7 @@ func (gui *Gui) handleFilePress(g *gocui.Gui, v *gocui.View) error {
|
||||
}
|
||||
|
||||
if file.HasInlineMergeConflicts {
|
||||
return gui.handleSwitchToMerge(g, v)
|
||||
return gui.handleSwitchToMerge()
|
||||
}
|
||||
|
||||
if file.HasUnstagedChanges {
|
||||
@ -284,13 +284,13 @@ func (gui *Gui) handleWIPCommitPress(g *gocui.Gui, filesView *gocui.View) error
|
||||
return err
|
||||
}
|
||||
|
||||
return gui.handleCommitPress(g, filesView)
|
||||
return gui.handleCommitPress()
|
||||
}
|
||||
|
||||
func (gui *Gui) handleCommitPress(g *gocui.Gui, filesView *gocui.View) error {
|
||||
func (gui *Gui) handleCommitPress() error {
|
||||
if len(gui.stagedFiles()) == 0 {
|
||||
return gui.promptToStageAllAndRetry(func() error {
|
||||
return gui.handleCommitPress(gui.g, filesView)
|
||||
return gui.handleCommitPress()
|
||||
})
|
||||
}
|
||||
|
||||
@ -309,12 +309,12 @@ func (gui *Gui) handleCommitPress(g *gocui.Gui, filesView *gocui.View) error {
|
||||
}
|
||||
}
|
||||
|
||||
g.Update(func(g *gocui.Gui) error {
|
||||
gui.g.Update(func(g *gocui.Gui) error {
|
||||
if _, err := g.SetViewOnTop("commitMessage"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := gui.switchFocus(filesView, commitMessageView); err != nil {
|
||||
if err := gui.switchFocus(gui.getFilesView(), commitMessageView); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -343,10 +343,10 @@ func (gui *Gui) promptToStageAllAndRetry(retry func() error) error {
|
||||
})
|
||||
}
|
||||
|
||||
func (gui *Gui) handleAmendCommitPress(g *gocui.Gui, filesView *gocui.View) error {
|
||||
func (gui *Gui) handleAmendCommitPress() error {
|
||||
if len(gui.stagedFiles()) == 0 {
|
||||
return gui.promptToStageAllAndRetry(func() error {
|
||||
return gui.handleAmendCommitPress(gui.g, filesView)
|
||||
return gui.handleAmendCommitPress()
|
||||
})
|
||||
}
|
||||
|
||||
@ -355,7 +355,7 @@ func (gui *Gui) handleAmendCommitPress(g *gocui.Gui, filesView *gocui.View) erro
|
||||
}
|
||||
|
||||
return gui.ask(askOpts{
|
||||
returnToView: filesView,
|
||||
returnToView: gui.getFilesView(),
|
||||
returnFocusOnClose: true,
|
||||
title: strings.Title(gui.Tr.SLocalize("AmendLastCommit")),
|
||||
prompt: gui.Tr.SLocalize("SureToAmend"),
|
||||
@ -375,21 +375,21 @@ func (gui *Gui) handleAmendCommitPress(g *gocui.Gui, filesView *gocui.View) erro
|
||||
|
||||
// handleCommitEditorPress - handle when the user wants to commit changes via
|
||||
// their editor rather than via the popup panel
|
||||
func (gui *Gui) handleCommitEditorPress(g *gocui.Gui, filesView *gocui.View) error {
|
||||
func (gui *Gui) handleCommitEditorPress() error {
|
||||
if len(gui.stagedFiles()) == 0 {
|
||||
return gui.promptToStageAllAndRetry(func() error {
|
||||
return gui.handleCommitEditorPress(gui.g, filesView)
|
||||
return gui.handleCommitEditorPress()
|
||||
})
|
||||
}
|
||||
|
||||
gui.PrepareSubProcess(g, "git", "commit")
|
||||
gui.PrepareSubProcess("git", "commit")
|
||||
return nil
|
||||
}
|
||||
|
||||
// PrepareSubProcess - prepare a subprocess for execution and tell the gui to switch to it
|
||||
func (gui *Gui) PrepareSubProcess(g *gocui.Gui, commands ...string) {
|
||||
func (gui *Gui) PrepareSubProcess(commands ...string) {
|
||||
gui.SubProcess = gui.GitCommand.PrepareCommitSubProcess()
|
||||
g.Update(func(g *gocui.Gui) error {
|
||||
gui.g.Update(func(g *gocui.Gui) error {
|
||||
return gui.Errors.ErrSubProcess
|
||||
})
|
||||
}
|
||||
@ -521,7 +521,7 @@ func (gui *Gui) pullWithMode(mode string, opts PullFilesOptions) error {
|
||||
}
|
||||
}
|
||||
|
||||
func (gui *Gui) pushWithForceFlag(g *gocui.Gui, v *gocui.View, force bool, upstream string, args string) error {
|
||||
func (gui *Gui) pushWithForceFlag(v *gocui.View, force bool, upstream string, args string) error {
|
||||
if err := gui.createLoaderPanel(v, gui.Tr.SLocalize("PushWait")); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -535,7 +535,7 @@ func (gui *Gui) pushWithForceFlag(g *gocui.Gui, v *gocui.View, force bool, upstr
|
||||
title: gui.Tr.SLocalize("ForcePush"),
|
||||
prompt: gui.Tr.SLocalize("ForcePushPrompt"),
|
||||
handleConfirm: func() error {
|
||||
return gui.pushWithForceFlag(gui.g, v, true, upstream, args)
|
||||
return gui.pushWithForceFlag(v, true, upstream, args)
|
||||
},
|
||||
})
|
||||
|
||||
@ -559,19 +559,19 @@ func (gui *Gui) pushFiles(g *gocui.Gui, v *gocui.View) error {
|
||||
}
|
||||
for branchName, branch := range conf.Branches {
|
||||
if branchName == currentBranch.Name {
|
||||
return gui.pushWithForceFlag(g, v, false, "", fmt.Sprintf("%s %s", branch.Remote, branchName))
|
||||
return gui.pushWithForceFlag(v, false, "", fmt.Sprintf("%s %s", branch.Remote, branchName))
|
||||
}
|
||||
}
|
||||
|
||||
if gui.GitCommand.PushToCurrent {
|
||||
return gui.pushWithForceFlag(g, v, false, "", "--set-upstream")
|
||||
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.pushWithForceFlag(g, v, false, response, "")
|
||||
return gui.pushWithForceFlag(v, false, response, "")
|
||||
})
|
||||
}
|
||||
} else if currentBranch.Pullables == "0" {
|
||||
return gui.pushWithForceFlag(g, v, false, "", "")
|
||||
return gui.pushWithForceFlag(v, false, "", "")
|
||||
}
|
||||
|
||||
return gui.ask(askOpts{
|
||||
@ -580,12 +580,12 @@ func (gui *Gui) pushFiles(g *gocui.Gui, v *gocui.View) error {
|
||||
title: gui.Tr.SLocalize("ForcePush"),
|
||||
prompt: gui.Tr.SLocalize("ForcePushPrompt"),
|
||||
handleConfirm: func() error {
|
||||
return gui.pushWithForceFlag(g, v, true, "", "")
|
||||
return gui.pushWithForceFlag(v, true, "", "")
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func (gui *Gui) handleSwitchToMerge(g *gocui.Gui, v *gocui.View) error {
|
||||
func (gui *Gui) handleSwitchToMerge() error {
|
||||
file, err := gui.getSelectedFile()
|
||||
if err != nil {
|
||||
if err != gui.Errors.ErrNoFiles {
|
||||
@ -597,7 +597,7 @@ func (gui *Gui) handleSwitchToMerge(g *gocui.Gui, v *gocui.View) error {
|
||||
return gui.createErrorPanel(gui.Tr.SLocalize("FileNoMergeCons"))
|
||||
}
|
||||
gui.changeMainViewsContext("merging")
|
||||
if err := gui.switchFocus(v, gui.getMainView()); err != nil {
|
||||
if err := gui.switchFocus(gui.g.CurrentView(), gui.getMainView()); err != nil {
|
||||
return err
|
||||
}
|
||||
return gui.refreshMergePanel()
|
||||
|
@ -202,7 +202,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||
ViewName: "",
|
||||
Key: gui.getKey("universal.quit"),
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleQuit,
|
||||
Handler: gui.wrappedHandler(gui.handleQuit),
|
||||
},
|
||||
{
|
||||
ViewName: "",
|
||||
@ -214,7 +214,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||
ViewName: "",
|
||||
Key: gui.getKey("universal.quit-alt1"),
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleQuit,
|
||||
Handler: gui.wrappedHandler(gui.handleQuit),
|
||||
},
|
||||
{
|
||||
ViewName: "",
|
||||
@ -263,7 +263,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||
{
|
||||
ViewName: "",
|
||||
Key: gui.getKey("universal.createRebaseOptionsMenu"),
|
||||
Handler: gui.handleCreateRebaseOptionsMenu,
|
||||
Handler: gui.wrappedHandler(gui.handleCreateRebaseOptionsMenu),
|
||||
Description: gui.Tr.SLocalize("ViewMergeRebaseOptions"),
|
||||
},
|
||||
{
|
||||
@ -353,13 +353,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||
{
|
||||
ViewName: "status",
|
||||
Key: gui.getKey("status.recentRepos"),
|
||||
Handler: gui.handleCreateRecentReposMenu,
|
||||
Handler: gui.wrappedHandler(gui.handleCreateRecentReposMenu),
|
||||
Description: gui.Tr.SLocalize("SwitchRepo"),
|
||||
},
|
||||
{
|
||||
ViewName: "files",
|
||||
Key: gui.getKey("files.commitChanges"),
|
||||
Handler: gui.handleCommitPress,
|
||||
Handler: gui.wrappedHandler(gui.handleCommitPress),
|
||||
Description: gui.Tr.SLocalize("CommitChanges"),
|
||||
},
|
||||
{
|
||||
@ -371,19 +371,19 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||
{
|
||||
ViewName: "files",
|
||||
Key: gui.getKey("files.amendLastCommit"),
|
||||
Handler: gui.handleAmendCommitPress,
|
||||
Handler: gui.wrappedHandler(gui.handleAmendCommitPress),
|
||||
Description: gui.Tr.SLocalize("AmendLastCommit"),
|
||||
},
|
||||
{
|
||||
ViewName: "files",
|
||||
Key: gui.getKey("files.commitChangesWithEditor"),
|
||||
Handler: gui.handleCommitEditorPress,
|
||||
Handler: gui.wrappedHandler(gui.handleCommitEditorPress),
|
||||
Description: gui.Tr.SLocalize("CommitChangesWithEditor"),
|
||||
},
|
||||
{
|
||||
ViewName: "files",
|
||||
Key: gui.getKey("universal.select"),
|
||||
Handler: gui.handleFilePress,
|
||||
Handler: gui.wrappedHandler(gui.handleFilePress),
|
||||
Description: gui.Tr.SLocalize("toggleStaged"),
|
||||
},
|
||||
{
|
||||
@ -765,7 +765,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||
ViewName: "commits",
|
||||
Contexts: []string{"branch-commits"},
|
||||
Key: gui.getKey("universal.goInto"),
|
||||
Handler: gui.handleSwitchToCommitFilesPanel,
|
||||
Handler: gui.wrappedHandler(gui.handleSwitchToCommitFilesPanel),
|
||||
Description: gui.Tr.SLocalize("viewCommitFiles"),
|
||||
},
|
||||
{
|
||||
@ -964,7 +964,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||
ViewName: "main",
|
||||
Contexts: []string{"staging"},
|
||||
Key: gui.getKey("universal.return"),
|
||||
Handler: gui.handleStagingEscape,
|
||||
Handler: gui.wrappedHandler(gui.handleStagingEscape),
|
||||
Description: gui.Tr.SLocalize("ReturnToFilesPanel"),
|
||||
},
|
||||
{
|
||||
@ -992,7 +992,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||
ViewName: "main",
|
||||
Contexts: []string{"patch-building"},
|
||||
Key: gui.getKey("universal.return"),
|
||||
Handler: gui.handleEscapePatchBuildingPanel,
|
||||
Handler: gui.wrappedHandler(gui.handleEscapePatchBuildingPanel),
|
||||
Description: gui.Tr.SLocalize("ExitLineByLineMode"),
|
||||
},
|
||||
{
|
||||
@ -1147,7 +1147,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||
ViewName: "main",
|
||||
Contexts: []string{"staging"},
|
||||
Key: gui.getKey("files.commitChanges"),
|
||||
Handler: gui.handleCommitPress,
|
||||
Handler: gui.wrappedHandler(gui.handleCommitPress),
|
||||
Description: gui.Tr.SLocalize("CommitChanges"),
|
||||
},
|
||||
{
|
||||
@ -1161,14 +1161,14 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||
ViewName: "main",
|
||||
Contexts: []string{"staging"},
|
||||
Key: gui.getKey("files.commitChangesWithEditor"),
|
||||
Handler: gui.handleCommitEditorPress,
|
||||
Handler: gui.wrappedHandler(gui.handleCommitEditorPress),
|
||||
Description: gui.Tr.SLocalize("CommitChangesWithEditor"),
|
||||
},
|
||||
{
|
||||
ViewName: "main",
|
||||
Contexts: []string{"merging"},
|
||||
Key: gui.getKey("universal.return"),
|
||||
Handler: gui.handleEscapeMerge,
|
||||
Handler: gui.wrappedHandler(gui.handleEscapeMerge),
|
||||
Description: gui.Tr.SLocalize("ReturnToFilesPanel"),
|
||||
},
|
||||
{
|
||||
@ -1267,7 +1267,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||
Contexts: []string{"remotes"},
|
||||
Key: gui.getKey("universal.goInto"),
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleRemoteEnter,
|
||||
Handler: gui.wrappedHandler(gui.handleRemoteEnter),
|
||||
},
|
||||
{
|
||||
ViewName: "branches",
|
||||
|
@ -393,7 +393,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
|
||||
// if you download humanlog and do tail -f development.log | humanlog
|
||||
// this will let you see these branches as prettified json
|
||||
// gui.Log.Info(utils.AsJson(gui.State.Branches[0:4]))
|
||||
return gui.resizeCurrentPopupPanel(g)
|
||||
return gui.resizeCurrentPopupPanel()
|
||||
}
|
||||
|
||||
func (gui *Gui) onInitialViewsCreation() error {
|
||||
|
@ -123,7 +123,7 @@ func (gui *Gui) getListViews() []*listView {
|
||||
getSelectedLineIdxPtr: func() *int { return &gui.State.Panels.Files.SelectedLine },
|
||||
handleFocus: gui.wrappedHandler(gui.focusAndSelectFile),
|
||||
handleItemSelect: gui.wrappedHandler(gui.focusAndSelectFile),
|
||||
handleClickSelectedItem: gui.handleFilePress,
|
||||
handleClickSelectedItem: gui.wrappedHandler(gui.handleFilePress),
|
||||
gui: gui,
|
||||
rendersToMainView: true,
|
||||
},
|
||||
@ -144,7 +144,7 @@ func (gui *Gui) getListViews() []*listView {
|
||||
getSelectedLineIdxPtr: func() *int { return &gui.State.Panels.Remotes.SelectedLine },
|
||||
handleFocus: gui.wrappedHandler(gui.renderRemotesWithSelection),
|
||||
handleItemSelect: gui.wrappedHandler(gui.handleRemoteSelect),
|
||||
handleClickSelectedItem: gui.handleRemoteEnter,
|
||||
handleClickSelectedItem: gui.wrappedHandler(gui.handleRemoteEnter),
|
||||
gui: gui,
|
||||
rendersToMainView: true,
|
||||
},
|
||||
@ -176,7 +176,7 @@ func (gui *Gui) getListViews() []*listView {
|
||||
getSelectedLineIdxPtr: func() *int { return &gui.State.Panels.Commits.SelectedLine },
|
||||
handleFocus: gui.wrappedHandler(gui.handleCommitSelect),
|
||||
handleItemSelect: gui.wrappedHandler(gui.handleCommitSelect),
|
||||
handleClickSelectedItem: gui.handleSwitchToCommitFilesPanel,
|
||||
handleClickSelectedItem: gui.wrappedHandler(gui.handleSwitchToCommitFilesPanel),
|
||||
gui: gui,
|
||||
rendersToMainView: true,
|
||||
},
|
||||
|
@ -42,7 +42,7 @@ func (gui *Gui) handleMenuClose(g *gocui.Gui, v *gocui.View) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return gui.returnFocus(g, v)
|
||||
return gui.returnFocus(v)
|
||||
}
|
||||
|
||||
type createMenuOptions struct {
|
||||
@ -73,7 +73,7 @@ func (gui *Gui) createMenu(title string, items []*menuItem, createMenuOptions cr
|
||||
|
||||
list := utils.RenderDisplayStrings(stringArrays)
|
||||
|
||||
x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(gui.g, false, list)
|
||||
x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(false, list)
|
||||
menuView, _ := gui.g.SetView("menu", x0, y0, x1, y1, 0)
|
||||
menuView.Title = title
|
||||
menuView.FgColor = theme.GocuiDefaultTextColor
|
||||
@ -99,7 +99,7 @@ func (gui *Gui) createMenu(title string, items []*menuItem, createMenuOptions cr
|
||||
}
|
||||
}
|
||||
|
||||
return gui.returnFocus(gui.g, menuView)
|
||||
return gui.returnFocus(menuView)
|
||||
}
|
||||
|
||||
gui.State.Panels.Menu.OnPress = wrappedHandlePress
|
||||
|
@ -112,7 +112,7 @@ func (gui *Gui) isIndexToDelete(i int, conflict commands.Conflict, pick string)
|
||||
(pick == "top" && i > conflict.Middle && i < conflict.End)
|
||||
}
|
||||
|
||||
func (gui *Gui) resolveConflict(g *gocui.Gui, conflict commands.Conflict, pick string) error {
|
||||
func (gui *Gui) resolveConflict(conflict commands.Conflict, pick string) error {
|
||||
gitFile, err := gui.getSelectedFile()
|
||||
if err != nil {
|
||||
return err
|
||||
@ -179,7 +179,7 @@ func (gui *Gui) handlePickHunk(g *gocui.Gui, v *gocui.View) error {
|
||||
if gui.State.Panels.Merging.ConflictTop {
|
||||
pick = "top"
|
||||
}
|
||||
err := gui.resolveConflict(g, conflict, pick)
|
||||
err := gui.resolveConflict(conflict, pick)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -200,7 +200,7 @@ func (gui *Gui) handlePickBothHunks(g *gocui.Gui, v *gocui.View) error {
|
||||
if err := gui.pushFileSnapshot(g); err != nil {
|
||||
return err
|
||||
}
|
||||
err := gui.resolveConflict(g, conflict, "both")
|
||||
err := gui.resolveConflict(conflict, "both")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -298,7 +298,7 @@ func (gui *Gui) renderMergeOptions() error {
|
||||
})
|
||||
}
|
||||
|
||||
func (gui *Gui) handleEscapeMerge(g *gocui.Gui, v *gocui.View) error {
|
||||
func (gui *Gui) handleEscapeMerge() error {
|
||||
gui.takeOverScrolling()
|
||||
|
||||
gui.State.Panels.Merging.EditHistory = stack.New()
|
||||
@ -308,7 +308,7 @@ func (gui *Gui) handleEscapeMerge(g *gocui.Gui, v *gocui.View) error {
|
||||
// it's possible this method won't be called from the merging view so we need to
|
||||
// ensure we only 'return' focus if we already have it
|
||||
if gui.g.CurrentView() == gui.getMainView() {
|
||||
return gui.switchFocus(v, gui.getFilesView())
|
||||
return gui.switchFocus(gui.getMainView(), gui.getFilesView())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -323,13 +323,13 @@ func (gui *Gui) handleCompleteMerge() error {
|
||||
// if we got conflicts after unstashing, we don't want to call any git
|
||||
// commands to continue rebasing/merging here
|
||||
if gui.GitCommand.WorkingTreeState() == "normal" {
|
||||
return gui.handleEscapeMerge(gui.g, gui.getMainView())
|
||||
return gui.handleEscapeMerge()
|
||||
}
|
||||
// if there are no more files with merge conflicts, we should ask whether the user wants to continue
|
||||
if !gui.anyFilesWithMergeConflicts() {
|
||||
return gui.promptToContinue()
|
||||
}
|
||||
return gui.handleEscapeMerge(gui.g, gui.getMainView())
|
||||
return gui.handleEscapeMerge()
|
||||
}
|
||||
|
||||
// promptToContinue asks the user if they want to continue the rebase/merge that's in progress
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
|
||||
func (gui *Gui) refreshPatchBuildingPanel(selectedLineIdx int) error {
|
||||
if !gui.GitCommand.PatchManager.CommitSelected() {
|
||||
return gui.handleEscapePatchBuildingPanel(gui.g, nil)
|
||||
return gui.handleEscapePatchBuildingPanel()
|
||||
}
|
||||
|
||||
gui.State.SplitMainPanel = true
|
||||
@ -38,7 +38,7 @@ func (gui *Gui) refreshPatchBuildingPanel(selectedLineIdx int) error {
|
||||
}
|
||||
|
||||
if empty {
|
||||
return gui.handleEscapePatchBuildingPanel(gui.g, nil)
|
||||
return gui.handleEscapePatchBuildingPanel()
|
||||
}
|
||||
|
||||
return nil
|
||||
@ -75,7 +75,7 @@ func (gui *Gui) handleToggleSelectionForPatch(g *gocui.Gui, v *gocui.View) error
|
||||
return nil
|
||||
}
|
||||
|
||||
func (gui *Gui) handleEscapePatchBuildingPanel(g *gocui.Gui, v *gocui.View) error {
|
||||
func (gui *Gui) handleEscapePatchBuildingPanel() error {
|
||||
gui.handleEscapeLineByLinePanel()
|
||||
|
||||
if gui.GitCommand.PatchManager.IsEmpty() {
|
||||
|
@ -78,7 +78,7 @@ func (gui *Gui) validateNormalWorkingTreeState() (bool, error) {
|
||||
|
||||
func (gui *Gui) returnFocusFromLineByLinePanelIfNecessary() error {
|
||||
if gui.State.MainContext == "patch-building" {
|
||||
return gui.handleEscapePatchBuildingPanel(gui.g, nil)
|
||||
return gui.handleEscapePatchBuildingPanel()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -26,12 +26,12 @@ func (gui *Gui) recordCurrentDirectory() error {
|
||||
|
||||
func (gui *Gui) handleQuitWithoutChangingDirectory(g *gocui.Gui, v *gocui.View) error {
|
||||
gui.State.RetainOriginalDir = true
|
||||
return gui.quit(v)
|
||||
return gui.quit()
|
||||
}
|
||||
|
||||
func (gui *Gui) handleQuit(g *gocui.Gui, v *gocui.View) error {
|
||||
func (gui *Gui) handleQuit() error {
|
||||
gui.State.RetainOriginalDir = false
|
||||
return gui.quit(v)
|
||||
return gui.quit()
|
||||
}
|
||||
|
||||
func (gui *Gui) handleTopLevelReturn(g *gocui.Gui, v *gocui.View) error {
|
||||
@ -43,20 +43,20 @@ func (gui *Gui) handleTopLevelReturn(g *gocui.Gui, v *gocui.View) error {
|
||||
}
|
||||
|
||||
if gui.Config.GetUserConfig().GetBool("quitOnTopLevelReturn") {
|
||||
return gui.handleQuit(g, v)
|
||||
return gui.handleQuit()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (gui *Gui) quit(v *gocui.View) error {
|
||||
func (gui *Gui) quit() error {
|
||||
if gui.State.Updating {
|
||||
return gui.createUpdateQuitConfirmation(gui.g, v)
|
||||
return gui.createUpdateQuitConfirmation()
|
||||
}
|
||||
|
||||
if gui.Config.GetUserConfig().GetBool("confirmOnQuit") {
|
||||
return gui.ask(askOpts{
|
||||
returnToView: v,
|
||||
returnToView: gui.g.CurrentView(),
|
||||
returnFocusOnClose: true,
|
||||
title: "",
|
||||
prompt: gui.Tr.SLocalize("ConfirmQuit"),
|
||||
|
@ -3,11 +3,9 @@ package gui
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/jesseduffield/gocui"
|
||||
)
|
||||
|
||||
func (gui *Gui) handleCreateRebaseOptionsMenu(g *gocui.Gui, v *gocui.View) error {
|
||||
func (gui *Gui) handleCreateRebaseOptionsMenu() error {
|
||||
options := []string{"continue", "abort"}
|
||||
|
||||
if gui.GitCommand.WorkingTreeState() == "rebasing" {
|
||||
|
@ -5,12 +5,11 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/jesseduffield/gocui"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
)
|
||||
|
||||
func (gui *Gui) handleCreateRecentReposMenu(g *gocui.Gui, v *gocui.View) error {
|
||||
func (gui *Gui) handleCreateRecentReposMenu() error {
|
||||
recentRepoPaths := gui.Config.GetAppState().RecentRepos
|
||||
reposCount := utils.Min(len(recentRepoPaths), 20)
|
||||
yellow := color.New(color.FgMagenta)
|
||||
|
@ -96,7 +96,7 @@ func (gui *Gui) renderRemotesWithSelection() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (gui *Gui) handleRemoteEnter(g *gocui.Gui, v *gocui.View) error {
|
||||
func (gui *Gui) handleRemoteEnter() error {
|
||||
// naive implementation: get the branches and render them to the list, change the context
|
||||
remote := gui.getSelectedRemote()
|
||||
if remote == nil {
|
||||
|
@ -24,11 +24,11 @@ func (gui *Gui) refreshStagingPanel(forceSecondaryFocused bool, selectedLineIdx
|
||||
if err != gui.Errors.ErrNoFiles {
|
||||
return err
|
||||
}
|
||||
return gui.handleStagingEscape(gui.g, nil)
|
||||
return gui.handleStagingEscape()
|
||||
}
|
||||
|
||||
if !file.HasUnstagedChanges && !file.HasStagedChanges {
|
||||
return gui.handleStagingEscape(gui.g, nil)
|
||||
return gui.handleStagingEscape()
|
||||
}
|
||||
|
||||
secondaryFocused := false
|
||||
@ -60,7 +60,7 @@ func (gui *Gui) refreshStagingPanel(forceSecondaryFocused bool, selectedLineIdx
|
||||
// 4-5 lines in which case we'll swap panels
|
||||
if len(strings.Split(diff, "\n")) < 5 {
|
||||
if len(strings.Split(secondaryDiff, "\n")) < 5 {
|
||||
return gui.handleStagingEscape(gui.g, nil)
|
||||
return gui.handleStagingEscape()
|
||||
}
|
||||
secondaryFocused = !secondaryFocused
|
||||
diff, secondaryDiff = secondaryDiff, diff
|
||||
@ -72,7 +72,7 @@ func (gui *Gui) refreshStagingPanel(forceSecondaryFocused bool, selectedLineIdx
|
||||
}
|
||||
|
||||
if empty {
|
||||
return gui.handleStagingEscape(gui.g, nil)
|
||||
return gui.handleStagingEscape()
|
||||
}
|
||||
|
||||
return nil
|
||||
@ -93,7 +93,7 @@ func (gui *Gui) handleTogglePanel(g *gocui.Gui, v *gocui.View) error {
|
||||
return gui.refreshStagingPanel(false, -1)
|
||||
}
|
||||
|
||||
func (gui *Gui) handleStagingEscape(g *gocui.Gui, v *gocui.View) error {
|
||||
func (gui *Gui) handleStagingEscape() error {
|
||||
gui.handleEscapeLineByLinePanel()
|
||||
|
||||
return gui.switchFocus(nil, gui.getFilesView())
|
||||
|
@ -69,7 +69,7 @@ func (gui *Gui) handleStashApply(g *gocui.Gui, v *gocui.View) error {
|
||||
skipStashWarning := gui.Config.GetUserConfig().GetBool("gui.skipStashWarning")
|
||||
|
||||
apply := func() error {
|
||||
return gui.stashDo(g, v, "apply")
|
||||
return gui.stashDo("apply")
|
||||
}
|
||||
|
||||
if skipStashWarning {
|
||||
@ -91,7 +91,7 @@ func (gui *Gui) handleStashPop(g *gocui.Gui, v *gocui.View) error {
|
||||
skipStashWarning := gui.Config.GetUserConfig().GetBool("gui.skipStashWarning")
|
||||
|
||||
pop := func() error {
|
||||
return gui.stashDo(g, v, "pop")
|
||||
return gui.stashDo("pop")
|
||||
}
|
||||
|
||||
if skipStashWarning {
|
||||
@ -116,12 +116,12 @@ func (gui *Gui) handleStashDrop(g *gocui.Gui, v *gocui.View) error {
|
||||
title: gui.Tr.SLocalize("StashDrop"),
|
||||
prompt: gui.Tr.SLocalize("SureDropStashEntry"),
|
||||
handleConfirm: func() error {
|
||||
return gui.stashDo(g, v, "drop")
|
||||
return gui.stashDo("drop")
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func (gui *Gui) stashDo(g *gocui.Gui, v *gocui.View, method string) error {
|
||||
func (gui *Gui) stashDo(method string) error {
|
||||
stashEntry := gui.getSelectedStashEntry()
|
||||
if stashEntry == nil {
|
||||
errorMessage := gui.Tr.TemplateLocalize(
|
||||
|
@ -70,14 +70,14 @@ func (gui *Gui) handleStatusClick(g *gocui.Gui, v *gocui.View) error {
|
||||
case "rebasing", "merging":
|
||||
workingTreeStatus := fmt.Sprintf("(%s)", gui.GitCommand.WorkingTreeState())
|
||||
if cursorInSubstring(cx, upstreamStatus+" ", workingTreeStatus) {
|
||||
return gui.handleCreateRebaseOptionsMenu(gui.g, v)
|
||||
return gui.handleCreateRebaseOptionsMenu()
|
||||
}
|
||||
if cursorInSubstring(cx, upstreamStatus+" "+workingTreeStatus+" ", repoName) {
|
||||
return gui.handleCreateRecentReposMenu(gui.g, v)
|
||||
return gui.handleCreateRecentReposMenu()
|
||||
}
|
||||
default:
|
||||
if cursorInSubstring(cx, upstreamStatus+" ", repoName) {
|
||||
return gui.handleCreateRecentReposMenu(gui.g, v)
|
||||
return gui.handleCreateRecentReposMenu()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,9 +59,9 @@ func (gui *Gui) onUpdateFinish(err error) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (gui *Gui) createUpdateQuitConfirmation(g *gocui.Gui, v *gocui.View) error {
|
||||
func (gui *Gui) createUpdateQuitConfirmation() error {
|
||||
return gui.ask(askOpts{
|
||||
returnToView: v,
|
||||
returnToView: gui.g.CurrentView(),
|
||||
returnFocusOnClose: true,
|
||||
title: "Currently Updating",
|
||||
prompt: "An update is in progress. Are you sure you want to quit?",
|
||||
|
@ -216,7 +216,7 @@ func (gui *Gui) previousView(g *gocui.Gui, v *gocui.View) error {
|
||||
return gui.switchFocus(v, focusedView)
|
||||
}
|
||||
|
||||
func (gui *Gui) newLineFocused(g *gocui.Gui, v *gocui.View) error {
|
||||
func (gui *Gui) newLineFocused(v *gocui.View) error {
|
||||
switch v.Name() {
|
||||
case "menu":
|
||||
return gui.handleMenuSelect()
|
||||
@ -263,11 +263,11 @@ func (gui *Gui) newLineFocused(g *gocui.Gui, v *gocui.View) error {
|
||||
}
|
||||
}
|
||||
|
||||
func (gui *Gui) returnFocus(g *gocui.Gui, v *gocui.View) error {
|
||||
previousView, err := g.View(gui.State.PreviousView)
|
||||
func (gui *Gui) returnFocus(v *gocui.View) error {
|
||||
previousView, err := gui.g.View(gui.State.PreviousView)
|
||||
if err != nil {
|
||||
// always fall back to files view if there's no 'previous' view stored
|
||||
previousView, err = g.View("files")
|
||||
previousView, err = gui.g.View("files")
|
||||
if err != nil {
|
||||
gui.Log.Error(err)
|
||||
}
|
||||
@ -293,7 +293,7 @@ func (gui *Gui) goToSideView(sideViewName string) func(g *gocui.Gui, v *gocui.Vi
|
||||
|
||||
func (gui *Gui) closePopupPanels() error {
|
||||
gui.onNewPopupPanel()
|
||||
err := gui.closeConfirmationPrompt(gui.g, true)
|
||||
err := gui.closeConfirmationPrompt(true)
|
||||
if err != nil {
|
||||
gui.Log.Error(err)
|
||||
return err
|
||||
@ -331,7 +331,7 @@ func (gui *Gui) switchFocus(oldView, newView *gocui.View) error {
|
||||
return err
|
||||
}
|
||||
|
||||
return gui.newLineFocused(gui.g, newView)
|
||||
return gui.newLineFocused(newView)
|
||||
}
|
||||
|
||||
func (gui *Gui) resetOrigin(v *gocui.View) error {
|
||||
@ -450,25 +450,25 @@ func (gui *Gui) currentViewName() string {
|
||||
return currentView.Name()
|
||||
}
|
||||
|
||||
func (gui *Gui) resizeCurrentPopupPanel(g *gocui.Gui) error {
|
||||
v := g.CurrentView()
|
||||
func (gui *Gui) resizeCurrentPopupPanel() error {
|
||||
v := gui.g.CurrentView()
|
||||
if gui.isPopupPanel(v.Name()) {
|
||||
return gui.resizePopupPanel(g, v)
|
||||
return gui.resizePopupPanel(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (gui *Gui) resizePopupPanel(g *gocui.Gui, v *gocui.View) error {
|
||||
func (gui *Gui) resizePopupPanel(v *gocui.View) error {
|
||||
// If the confirmation panel is already displayed, just resize the width,
|
||||
// otherwise continue
|
||||
content := v.Buffer()
|
||||
x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(g, v.Wrap, content)
|
||||
x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(v.Wrap, content)
|
||||
vx0, vy0, vx1, vy1 := v.Dimensions()
|
||||
if vx0 == x0 && vy0 == y0 && vx1 == x1 && vy1 == y1 {
|
||||
return nil
|
||||
}
|
||||
gui.Log.Info(gui.Tr.SLocalize("resizingPopupPanel"))
|
||||
_, err := g.SetView(v.Name(), x0, y0, x1, y1, 0)
|
||||
_, err := gui.g.SetView(v.Name(), x0, y0, x1, y1, 0)
|
||||
return err
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user