diff --git a/pkg/commands/git_commands/commit_loader.go b/pkg/commands/git_commands/commit_loader.go index 381dd641e..987f2394e 100644 --- a/pkg/commands/git_commands/commit_loader.go +++ b/pkg/commands/git_commands/commit_loader.go @@ -56,7 +56,7 @@ func NewCommitLoader( } type GetCommitsOptions struct { - Limit bool + Limit int // the maximum number of commits to load, or 0 to load all of them FilterPath string FilterAuthor string IncludeRebaseCommits bool @@ -611,7 +611,7 @@ func (self *CommitLoader) getLogCmd(opts GetCommitsOptions) *oscommands.CmdObj { Arg(prettyFormat). Arg("--abbrev=40"). ArgIf(opts.FilterAuthor != "", "--author="+opts.FilterAuthor). - ArgIf(opts.Limit, "-300"). + ArgIf(opts.Limit > 0, fmt.Sprintf("-%d", opts.Limit)). ArgIf(opts.FilterPath != "", "--follow", "--name-status"). Arg("--no-show-signature"). ArgIf(opts.RefToShowDivergenceFrom != "", "--left-right"). diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go index c367fd80b..f6fc539b2 100644 --- a/pkg/gui/controllers/helpers/refresh_helper.go +++ b/pkg/gui/controllers/helpers/refresh_helper.go @@ -758,6 +758,10 @@ func (self *RefreshHelper) refreshReflogAndBranches(capturedReflog capturedReflo return nil } +// The number of commits that the commits and sub-commits views load at first, +// to keep things fast. They load the rest when the user scrolls near the end. +const commitLimit = 300 + // capturedCommitState holds everything the commits refresh reads from the // model, contexts, and modes. It is gathered on the UI thread (see // captureCommitsState) before the git work is dispatched to a worker, so the @@ -852,7 +856,7 @@ func (self *RefreshHelper) refreshCommitsWithLimit(captured capturedCommitState, refName, bisectInfo := self.refForLog(env) commits, err := env.git.Loaders.CommitLoader.GetCommits( git_commands.GetCommitsOptions{ - Limit: captured.limitCommits, + Limit: lo.Ternary(captured.limitCommits, commitLimit, 0), FilterPath: captured.filterPath, FilterAuthor: captured.filterAuthor, IncludeRebaseCommits: true, @@ -1073,7 +1077,7 @@ func (self *RefreshHelper) refreshSubCommitsWithLimit(captured capturedSubCommit commits, err := env.git.Loaders.CommitLoader.GetCommits( git_commands.GetCommitsOptions{ - Limit: captured.limitCommits, + Limit: lo.Ternary(captured.limitCommits, commitLimit, 0), FilterPath: captured.filterPath, FilterAuthor: captured.filterAuthor, IncludeRebaseCommits: false, diff --git a/pkg/gui/controllers/helpers/sub_commits_helper.go b/pkg/gui/controllers/helpers/sub_commits_helper.go index 09f32d1a9..e3d02dd8c 100644 --- a/pkg/gui/controllers/helpers/sub_commits_helper.go +++ b/pkg/gui/controllers/helpers/sub_commits_helper.go @@ -34,7 +34,7 @@ type ViewSubCommitsOpts struct { func (self *SubCommitsHelper) ViewSubCommits(opts ViewSubCommitsOpts) error { commits, err := self.c.Git().Loaders.CommitLoader.GetCommits( git_commands.GetCommitsOptions{ - Limit: true, + Limit: commitLimit, FilterPath: self.c.Modes().Filtering.GetPath(), FilterAuthor: self.c.Modes().Filtering.GetAuthor(), IncludeRebaseCommits: false,