summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-03-28 13:57:16 +1100
committerJesse Duffield <jessedduffield@gmail.com>2020-03-28 14:02:53 +1100
commitfbb767893ea469f9173d32dd8aa165f77e5f4ba1 (patch)
treed70787ec29d3209771bc64d4fd15d9ec21a7bcdd
parent229f5ee48c75ca0c8a78345f9da44dc4b2b2e625 (diff)
support lazyloading in commits view
-rw-r--r--pkg/gui/commits_panel.go18
-rw-r--r--pkg/gui/keybindings.go35
2 files changed, 38 insertions, 15 deletions
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go
index b19e0c5d0..3d96555f0 100644
--- a/pkg/gui/commits_panel.go
+++ b/pkg/gui/commits_panel.go
@@ -668,3 +668,21 @@ func (gui *Gui) handleResetCherryPick(g *gocui.Gui, v *gocui.View) error {
gui.State.CherryPickedCommits = []*commands.Commit{}
return gui.renderBranchCommitsWithSelection()
}
+
+func (gui *Gui) handleGotoBottomForCommitsPanel(g *gocui.Gui, v *gocui.View) error {
+ // we usually lazyload these commits but now that we're searching we need to load them now
+ if gui.State.Panels.Commits.LimitCommits {
+ gui.State.Panels.Commits.LimitCommits = false
+ if err := gui.refreshSidePanels(refreshOptions{mode: SYNC, scope: []int{COMMITS}}); err != nil {
+ return err
+ }
+ }
+
+ for _, view := range gui.getListViews() {
+ if view.viewName == "commits" {
+ return view.handleGotoBottom(g, v)
+ }
+ }
+
+ return nil
+}
diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go
index c7b9546ad..98a269b8f 100644
--- a/pkg/gui/keybindings.go
+++ b/pkg/gui/keybindings.go
@@ -685,13 +685,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
},
{
ViewName: "commits",
- Key: gui.getKey("universal.startSearch"),
- Modifier: gocui.ModNone,
- Handler: gui.handleOpenSearchForCommitsPanel,
- Description: gui.Tr.SLocalize("startSearch"),
- },
- {
- ViewName: "commits",
Contexts: []string{"branch-commits"},
Key: gui.getKey("commits.squashDown"),
Modifier: gocui.ModNone,
@@ -1513,22 +1506,34 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
{ViewName: listView.viewName, Contexts: []string{listView.context}, Key: gui.getKey("universal.prevPage"), Modifier: gocui.ModNone, Handler: listView.handlePrevPage},
{ViewName: listView.viewName, Contexts: []string{listView.context}, Key: gui.getKey("universal.nextPage"), Modifier: gocui.ModNone, Handler: listView.handleNextPage},
{ViewName: listView.viewName, Contexts: []string{listView.context}, Key: gui.getKey("universal.gotoTop"), Modifier: gocui.ModNone, Handler: listView.handleGotoTop},
- {ViewName: listView.viewName, Contexts: []string{listView.context}, Key: gui.getKey("universal.gotoBottom"), Modifier: gocui.ModNone, Handler: listView.handleGotoBottom},
{ViewName: listView.viewName, Contexts: []string{listView.context}, Key: gocui.MouseWheelDown, Modifier: gocui.ModNone, Handler: listView.handleNextLine},
{ViewName: listView.viewName, Contexts: []string{listView.context}, Key: gocui.MouseLeft, Modifier: gocui.ModNone, Handler: listView.handleClick},
}...)
- // we need a specific keybinding for the commits panel beacuse it usually lazyloads commits
- if listView.viewName != "commits" {
- bindings = append(bindings, &Binding{
+ // the commits panel needs to lazyload things so it has a couple of its own handlers
+ openSearchHandler := gui.handleOpenSearch
+ gotoBottomHandler := listView.handleGotoBottom
+ if listView.viewName == "commits" {
+ openSearchHandler = gui.handleOpenSearchForCommitsPanel
+ gotoBottomHandler = gui.handleGotoBottomForCommitsPanel
+ }
+
+ bindings = append(bindings, []*Binding{
+ {
ViewName: listView.viewName,
- Contexts: []string{listView.context},
Key: gui.getKey("universal.startSearch"),
Modifier: gocui.ModNone,
- Handler: gui.handleOpenSearch,
+ Handler: openSearchHandler,
Description: gui.Tr.SLocalize("startSearch"),
- })
- }
+ },
+ {
+ ViewName: listView.viewName,
+ Contexts: []string{listView.context},
+ Key: gui.getKey("universal.gotoBottom"),
+ Modifier: gocui.ModNone,
+ Handler: gotoBottomHandler,
+ },
+ }...)
}
return bindings