1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-10 04:07:18 +02:00
This commit is contained in:
Jesse Duffield 2020-08-19 19:31:58 +10:00
parent e4beaf4de9
commit 2fac2f9f1f
7 changed files with 22 additions and 54 deletions

View File

@ -7,7 +7,6 @@ import (
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/commands"
"github.com/jesseduffield/lazygit/pkg/gui/presentation"
"github.com/jesseduffield/lazygit/pkg/utils"
)
// list panel functions
@ -439,26 +438,6 @@ func (gui *Gui) handleFastForward(g *gocui.Gui, v *gocui.View) error {
return nil
}
func (gui *Gui) onViewTabClick(viewName string, tabIndex int) error {
context := gui.ViewTabContextMap[viewName][tabIndex].contexts[0]
return gui.switchContext(context)
}
func (gui *Gui) handleNextTab(g *gocui.Gui, v *gocui.View) error {
return gui.onViewTabClick(
v.Name(),
utils.ModuloWithWrap(v.TabIndex+1, len(v.Tabs)),
)
}
func (gui *Gui) handlePrevTab(g *gocui.Gui, v *gocui.View) error {
return gui.onViewTabClick(
v.Name(),
utils.ModuloWithWrap(v.TabIndex-1, len(v.Tabs)),
)
}
func (gui *Gui) handleCreateResetToBranchMenu(g *gocui.Gui, v *gocui.View) error {
branch := gui.getSelectedBranch()
if branch == nil {

View File

@ -636,19 +636,6 @@ func (gui *Gui) renderBranchCommitsWithSelection() error {
return nil
}
func (gui *Gui) refreshCommitsViewWithSelection() error {
commitsView := gui.getCommitsView()
switch commitsView.Context {
case "branch-commits":
return gui.Contexts.BranchCommits.Context.HandleRender()
case "reflog-commits":
return gui.renderReflogCommitsWithSelection()
}
return nil
}
func (gui *Gui) handleCreateCommitResetMenu(g *gocui.Gui, v *gocui.View) error {
commit := gui.getSelectedCommit()
if commit == nil {

View File

@ -547,13 +547,9 @@ func (gui *Gui) viewTabNames(viewName string) []string {
}
func (gui *Gui) setViewTabForContext(c Context) {
gui.Log.Warnf("in set view tab: %s", c.GetKey())
// search for the context in our map and if we find it, set the tab for the corresponding view
tabContexts, ok := gui.ViewTabContextMap[c.GetViewName()]
if !ok {
gui.Log.Warnf("in set view tab: returning")
return
}
@ -566,7 +562,6 @@ func (gui *Gui) setViewTabForContext(c Context) {
gui.Log.Error(err)
return
}
gui.Log.Warnf("index: %d", tabIndex)
v.TabIndex = tabIndex
return
}

View File

@ -210,7 +210,7 @@ func (gui *Gui) remotesListContext() *ListContext {
ContextKey: "remotes",
GetItemsLength: func() int { return len(gui.State.Remotes) },
GetSelectedLineIdxPtr: func() *int { return &gui.State.Panels.Remotes.SelectedLine },
OnFocus: gui.renderRemotesWithSelection,
OnFocus: gui.handleRemoteSelect,
OnItemSelect: gui.handleRemoteSelect,
OnClickSelectedItem: gui.handleRemoteEnter,
OnRender: gui.renderRemotesWithSelection,

View File

@ -57,11 +57,6 @@ func (gui *Gui) renderRemoteBranchesWithSelection() error {
gui.refreshSelectedLine(&gui.State.Panels.RemoteBranches.SelectedLine, len(gui.State.RemoteBranches))
displayStrings := presentation.GetRemoteBranchListDisplayStrings(gui.State.RemoteBranches, gui.State.Diff.Ref)
gui.renderDisplayStrings(branchesView, displayStrings)
if gui.g.CurrentView() == branchesView && branchesView.Context == "remote-branches" {
if err := gui.handleRemoteBranchSelect(); err != nil {
return err
}
}
return nil
}

View File

@ -67,15 +67,7 @@ func (gui *Gui) refreshRemotes() error {
}
}
// TODO: see if this works for deleting remote branches
switch gui.getBranchesView().Context {
case "remotes":
return gui.renderRemotesWithSelection()
case "remote-branches":
return gui.renderRemoteBranchesWithSelection()
}
return nil
return gui.postRefreshUpdate(gui.contextForContextKey(gui.getBranchesView().Context))
}
func (gui *Gui) renderRemotesWithSelection() error {

View File

@ -371,3 +371,23 @@ func (gui *Gui) clearEditorView(v *gocui.View) {
_ = v.SetCursor(0, 0)
_ = v.SetOrigin(0, 0)
}
func (gui *Gui) onViewTabClick(viewName string, tabIndex int) error {
context := gui.ViewTabContextMap[viewName][tabIndex].contexts[0]
return gui.switchContext(context)
}
func (gui *Gui) handleNextTab(g *gocui.Gui, v *gocui.View) error {
return gui.onViewTabClick(
v.Name(),
utils.ModuloWithWrap(v.TabIndex+1, len(v.Tabs)),
)
}
func (gui *Gui) handlePrevTab(g *gocui.Gui, v *gocui.View) error {
return gui.onViewTabClick(
v.Name(),
utils.ModuloWithWrap(v.TabIndex-1, len(v.Tabs)),
)
}