diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-01-11 18:23:35 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-01-12 10:10:56 +1100 |
commit | 282f08df36eb2939d1a1caf12457680b38089e0a (patch) | |
tree | ec468e4ba77b30025aa72e7a7d185a45a8735cf5 /pkg/gui | |
parent | d647a96ed55e134f1464878be8d0be3a464d996f (diff) |
lazyload commits
Diffstat (limited to 'pkg/gui')
-rw-r--r-- | pkg/gui/commits_panel.go | 48 | ||||
-rw-r--r-- | pkg/gui/gui.go | 3 |
2 files changed, 37 insertions, 14 deletions
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index 67c126aea..32672a40b 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -37,6 +37,16 @@ func (gui *Gui) handleCommitSelect(g *gocui.Gui, v *gocui.View) error { return err } + state := gui.State.Panels.Commits + if state.SelectedLine > 20 && state.LimitCommits { + state.LimitCommits = false + go func() { + if err := gui.refreshCommitsWithLimit(); err != nil { + _ = gui.createErrorPanel(gui.g, err.Error()) + } + }() + } + gui.getMainView().Title = "Patch" gui.getSecondaryView().Title = "Custom Patch" gui.State.Panels.LineByLine = nil @@ -64,15 +74,12 @@ func (gui *Gui) handleCommitSelect(g *gocui.Gui, v *gocui.View) error { func (gui *Gui) refreshCommits(g *gocui.Gui) error { g.Update(func(*gocui.Gui) error { - builder, err := commands.NewCommitListBuilder(gui.Log, gui.GitCommand, gui.OSCommand, gui.Tr, gui.State.CherryPickedCommits, gui.State.DiffEntries) - if err != nil { - return err - } - commits, err := builder.GetCommits() - if err != nil { + // I think this is here for the sake of some kind of rebasing thing + gui.refreshStatus(g) + + if err := gui.refreshCommitsWithLimit(); err != nil { return err } - gui.State.Commits = commits // doing this async because it shouldn't hold anything up go func() { @@ -81,12 +88,6 @@ func (gui *Gui) refreshCommits(g *gocui.Gui) error { } }() - gui.refreshStatus(g) - if gui.getCommitsView().Context == "branch-commits" { - if err := gui.renderBranchCommitsWithSelection(); err != nil { - return err - } - } if g.CurrentView() == gui.getCommitFilesView() || (g.CurrentView() == gui.getMainView() || gui.State.MainContext == "patch-building") { return gui.refreshCommitFilesView() } @@ -95,6 +96,27 @@ func (gui *Gui) refreshCommits(g *gocui.Gui) error { return nil } +func (gui *Gui) refreshCommitsWithLimit() error { + builder, err := commands.NewCommitListBuilder(gui.Log, gui.GitCommand, gui.OSCommand, gui.Tr, gui.State.CherryPickedCommits, gui.State.DiffEntries) + if err != nil { + return err + } + + commits, err := builder.GetCommits(gui.State.Panels.Commits.LimitCommits) + if err != nil { + return err + } + gui.State.Commits = commits + + if gui.getCommitsView().Context == "branch-commits" { + if err := gui.renderBranchCommitsWithSelection(); err != nil { + return err + } + } + + return nil +} + // specific functions func (gui *Gui) handleResetToCommit(g *gocui.Gui, commitView *gocui.View) error { diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 9bfeae6c4..2bdb66e0f 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -128,6 +128,7 @@ type tagsPanelState struct { type commitPanelState struct { SelectedLine int SpecificDiffMode bool + LimitCommits bool } type reflogCommitPanelState struct { @@ -212,7 +213,7 @@ func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *comma Remotes: &remotePanelState{SelectedLine: 0}, RemoteBranches: &remoteBranchesState{SelectedLine: -1}, Tags: &tagsPanelState{SelectedLine: -1}, - Commits: &commitPanelState{SelectedLine: -1}, + Commits: &commitPanelState{SelectedLine: -1, LimitCommits: true}, ReflogCommits: &reflogCommitPanelState{SelectedLine: 0}, // TODO: might need to make -1 CommitFiles: &commitFilesPanelState{SelectedLine: -1}, Stash: &stashPanelState{SelectedLine: -1}, |