summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pkg/gui/branches_panel.go21
-rw-r--r--pkg/gui/commits_panel.go13
-rw-r--r--pkg/gui/context.go5
-rw-r--r--pkg/gui/list_context.go2
-rw-r--r--pkg/gui/remote_branches_panel.go5
-rw-r--r--pkg/gui/remotes_panel.go10
-rw-r--r--pkg/gui/view_helpers.go20
7 files changed, 22 insertions, 54 deletions
diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go
index 80e7e154a..f8155db2d 100644
--- a/pkg/gui/branches_panel.go
+++ b/pkg/gui/branches_panel.go
@@ -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 {
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go
index 7f6e0a5e4..326a892e9 100644
--- a/pkg/gui/commits_panel.go
+++ b/pkg/gui/commits_panel.go
@@ -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 {
diff --git a/pkg/gui/context.go b/pkg/gui/context.go
index 559cfa108..cdfcc373f 100644
--- a/pkg/gui/context.go
+++ b/pkg/gui/context.go
@@ -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
}
diff --git a/pkg/gui/list_context.go b/pkg/gui/list_context.go
index 69ed01ef6..19cab887d 100644
--- a/pkg/gui/list_context.go
+++ b/pkg/gui/list_context.go
@@ -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,
diff --git a/pkg/gui/remote_branches_panel.go b/pkg/gui/remote_branches_panel.go
index f6c213de8..6e39c8cad 100644
--- a/pkg/gui/remote_branches_panel.go
+++ b/pkg/gui/remote_branches_panel.go
@@ -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
}
diff --git a/pkg/gui/remotes_panel.go b/pkg/gui/remotes_panel.go
index 24058ea84..32d69498d 100644
--- a/pkg/gui/remotes_panel.go
+++ b/pkg/gui/remotes_panel.go
@@ -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 {
diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go
index db5e32848..2c8f9066b 100644
--- a/pkg/gui/view_helpers.go
+++ b/pkg/gui/view_helpers.go
@@ -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)),
+ )
+}