mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-31 14:24:25 +03:00
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.
This commit is contained in:
@ -63,7 +63,7 @@ func (self *ListContextTrait) renderLines(startIdx int, endIdx int) string {
|
|||||||
columnAlignments = self.getColumnAlignments()
|
columnAlignments = self.getColumnAlignments()
|
||||||
}
|
}
|
||||||
return utils.RenderDisplayStrings(
|
return utils.RenderDisplayStrings(
|
||||||
self.getDisplayStrings(startIdx, endIdx),
|
self.getDisplayStrings(startIdx, utils.Min(endIdx, self.list.Len())),
|
||||||
columnAlignments)
|
columnAlignments)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,11 +68,10 @@ func GetCommitListDisplayStrings(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
end := utils.Min(endIdx, len(commits))
|
|
||||||
// this is where my non-TODO commits begin
|
// 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)
|
bisectBounds := getbisectBounds(commits, bisectInfo)
|
||||||
|
|
||||||
@ -85,8 +84,8 @@ func GetCommitListDisplayStrings(
|
|||||||
|
|
||||||
pipeSets := loadPipesets(commits[rebaseOffset:])
|
pipeSets := loadPipesets(commits[rebaseOffset:])
|
||||||
pipeSetOffset := utils.Max(startIdx-rebaseOffset, 0)
|
pipeSetOffset := utils.Max(startIdx-rebaseOffset, 0)
|
||||||
graphPipeSets := pipeSets[pipeSetOffset:utils.Max(end-rebaseOffset, 0)]
|
graphPipeSets := pipeSets[pipeSetOffset:utils.Max(endIdx-rebaseOffset, 0)]
|
||||||
graphCommits := commits[graphOffset:end]
|
graphCommits := commits[graphOffset:endIdx]
|
||||||
graphLines := graph.RenderAux(
|
graphLines := graph.RenderAux(
|
||||||
graphPipeSets,
|
graphPipeSets,
|
||||||
graphCommits,
|
graphCommits,
|
||||||
|
@ -247,7 +247,7 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
|
|||||||
{Name: "commit5", Sha: "sha5", Parents: []string{"sha7"}},
|
{Name: "commit5", Sha: "sha5", Parents: []string{"sha7"}},
|
||||||
},
|
},
|
||||||
startIdx: 1,
|
startIdx: 1,
|
||||||
endIdx: 11,
|
endIdx: 5,
|
||||||
showGraph: true,
|
showGraph: true,
|
||||||
bisectInfo: git_commands.NewNullBisectInfo(),
|
bisectInfo: git_commands.NewNullBisectInfo(),
|
||||||
cherryPickedCommitShaSet: set.New[string](),
|
cherryPickedCommitShaSet: set.New[string](),
|
||||||
@ -312,7 +312,7 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
|
|||||||
{Name: "commit5", Sha: "sha5", Parents: []string{"sha7"}},
|
{Name: "commit5", Sha: "sha5", Parents: []string{"sha7"}},
|
||||||
},
|
},
|
||||||
startIdx: 4,
|
startIdx: 4,
|
||||||
endIdx: 6,
|
endIdx: 5,
|
||||||
showGraph: true,
|
showGraph: true,
|
||||||
bisectInfo: git_commands.NewNullBisectInfo(),
|
bisectInfo: git_commands.NewNullBisectInfo(),
|
||||||
cherryPickedCommitShaSet: set.New[string](),
|
cherryPickedCommitShaSet: set.New[string](),
|
||||||
@ -351,7 +351,7 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
|
|||||||
{Name: "commit3", Sha: "sha3", Parents: []string{"sha4"}},
|
{Name: "commit3", Sha: "sha3", Parents: []string{"sha4"}},
|
||||||
},
|
},
|
||||||
startIdx: 0,
|
startIdx: 0,
|
||||||
endIdx: 5,
|
endIdx: 3,
|
||||||
showGraph: true,
|
showGraph: true,
|
||||||
bisectInfo: git_commands.NewNullBisectInfo(),
|
bisectInfo: git_commands.NewNullBisectInfo(),
|
||||||
cherryPickedCommitShaSet: set.New[string](),
|
cherryPickedCommitShaSet: set.New[string](),
|
||||||
|
Reference in New Issue
Block a user