diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2023-08-18 16:50:07 +0200 |
---|---|---|
committer | Stefan Haller <stefan@haller-berlin.de> | 2023-08-28 14:21:06 +0200 |
commit | 297a020abf806173d5e3bbf28deb98323b9037e5 (patch) | |
tree | 506c5e9c8e4f7ecfc9ac6bbee4187f6612469efa /pkg/gui/presentation | |
parent | 473d989cde342e38802c52d9117b12b1e5691077 (diff) |
Call getDisplayStrings with a valid range of model indices
It's nicer if clients can rely on the indices being valid, and don't have to
clamp themselves.
Diffstat (limited to 'pkg/gui/presentation')
-rw-r--r-- | pkg/gui/presentation/commits.go | 9 | ||||
-rw-r--r-- | pkg/gui/presentation/commits_test.go | 6 |
2 files changed, 7 insertions, 8 deletions
diff --git a/pkg/gui/presentation/commits.go b/pkg/gui/presentation/commits.go index 6bf711cce..6ae04f95a 100644 --- a/pkg/gui/presentation/commits.go +++ b/pkg/gui/presentation/commits.go @@ -68,11 +68,10 @@ func GetCommitListDisplayStrings( return nil } - end := utils.Min(endIdx, len(commits)) // this is where my non-TODO commits begin - rebaseOffset := utils.Min(indexOfFirstNonTODOCommit(commits), end) + rebaseOffset := utils.Min(indexOfFirstNonTODOCommit(commits), endIdx) - filteredCommits := commits[startIdx:end] + filteredCommits := commits[startIdx:endIdx] bisectBounds := getbisectBounds(commits, bisectInfo) @@ -85,8 +84,8 @@ func GetCommitListDisplayStrings( pipeSets := loadPipesets(commits[rebaseOffset:]) pipeSetOffset := utils.Max(startIdx-rebaseOffset, 0) - graphPipeSets := pipeSets[pipeSetOffset:utils.Max(end-rebaseOffset, 0)] - graphCommits := commits[graphOffset:end] + graphPipeSets := pipeSets[pipeSetOffset:utils.Max(endIdx-rebaseOffset, 0)] + graphCommits := commits[graphOffset:endIdx] graphLines := graph.RenderAux( graphPipeSets, graphCommits, diff --git a/pkg/gui/presentation/commits_test.go b/pkg/gui/presentation/commits_test.go index a25e004f5..493260ad2 100644 --- a/pkg/gui/presentation/commits_test.go +++ b/pkg/gui/presentation/commits_test.go @@ -247,7 +247,7 @@ func TestGetCommitListDisplayStrings(t *testing.T) { {Name: "commit5", Sha: "sha5", Parents: []string{"sha7"}}, }, startIdx: 1, - endIdx: 11, + endIdx: 5, showGraph: true, bisectInfo: git_commands.NewNullBisectInfo(), cherryPickedCommitShaSet: set.New[string](), @@ -312,7 +312,7 @@ func TestGetCommitListDisplayStrings(t *testing.T) { {Name: "commit5", Sha: "sha5", Parents: []string{"sha7"}}, }, startIdx: 4, - endIdx: 6, + endIdx: 5, showGraph: true, bisectInfo: git_commands.NewNullBisectInfo(), cherryPickedCommitShaSet: set.New[string](), @@ -351,7 +351,7 @@ func TestGetCommitListDisplayStrings(t *testing.T) { {Name: "commit3", Sha: "sha3", Parents: []string{"sha4"}}, }, startIdx: 0, - endIdx: 5, + endIdx: 3, showGraph: true, bisectInfo: git_commands.NewNullBisectInfo(), cherryPickedCommitShaSet: set.New[string](), |