1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-24 05:36:19 +02:00

fix branches select sig

This commit is contained in:
Jesse Duffield 2020-08-15 16:48:35 +10:00
parent 0822a9296c
commit b0fe963f8a
3 changed files with 8 additions and 9 deletions

View File

@ -21,15 +21,14 @@ func (gui *Gui) getSelectedBranch() *commands.Branch {
return gui.State.Branches[selectedLine]
}
// may want to standardise how these select methods work
func (gui *Gui) handleBranchSelect(g *gocui.Gui, v *gocui.View) error {
func (gui *Gui) handleBranchSelect() error {
if gui.popupPanelFocused() {
return nil
}
gui.State.SplitMainPanel = false
if _, err := gui.g.SetCurrentView(v.Name()); err != nil {
if _, err := gui.g.SetCurrentView("branches"); err != nil {
return err
}
@ -40,7 +39,7 @@ func (gui *Gui) handleBranchSelect(g *gocui.Gui, v *gocui.View) error {
return gui.newStringTask("main", gui.Tr.SLocalize("NoBranchesThisRepo"))
}
branch := gui.getSelectedBranch()
v.FocusPoint(0, gui.State.Panels.Branches.SelectedLine)
gui.getBranchesView().FocusPoint(0, gui.State.Panels.Branches.SelectedLine)
if gui.inDiffMode() {
return gui.renderDiff()
@ -92,7 +91,7 @@ func (gui *Gui) renderLocalBranchesWithSelection() error {
displayStrings := presentation.GetBranchListDisplayStrings(gui.State.Branches, gui.State.ScreenMode != SCREEN_NORMAL, gui.State.Diff.Ref)
gui.renderDisplayStrings(branchesView, displayStrings)
if gui.g.CurrentView() == branchesView {
if err := gui.handleBranchSelect(gui.g, branchesView); err != nil {
if err := gui.handleBranchSelect(); err != nil {
return gui.surfaceError(err)
}
}
@ -516,7 +515,7 @@ func (gui *Gui) onBranchesPanelSearchSelect(selectedLine int) error {
switch branchesView.Context {
case "local-branches":
gui.State.Panels.Branches.SelectedLine = selectedLine
return gui.handleBranchSelect(gui.g, branchesView)
return gui.handleBranchSelect()
case "remotes":
gui.State.Panels.Remotes.SelectedLine = selectedLine
return gui.handleRemoteSelect(gui.g, branchesView)

View File

@ -132,8 +132,8 @@ func (gui *Gui) getListViews() []*listView {
context: "local-branches",
getItemsLength: func() int { return len(gui.State.Branches) },
getSelectedLineIdxPtr: func() *int { return &gui.State.Panels.Branches.SelectedLine },
handleFocus: gui.handleBranchSelect,
handleItemSelect: gui.handleBranchSelect,
handleFocus: gui.wrappedHandler(gui.handleBranchSelect),
handleItemSelect: gui.wrappedHandler(gui.handleBranchSelect),
gui: gui,
rendersToMainView: true,
},

View File

@ -228,7 +228,7 @@ func (gui *Gui) newLineFocused(g *gocui.Gui, v *gocui.View) error {
branchesView := gui.getBranchesView()
switch branchesView.Context {
case "local-branches":
return gui.handleBranchSelect(g, v)
return gui.handleBranchSelect()
case "remotes":
return gui.handleRemoteSelect(g, v)
case "remote-branches":