mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 12:55:47 +02:00
use generics to DRY up context code
This commit is contained in:
parent
4b56d428ff
commit
d93fef4c61
31 changed files with 117 additions and 364 deletions
|
@ -8,7 +8,7 @@ import (
|
|||
type ICommitFileTree interface {
|
||||
ITree
|
||||
|
||||
GetItemAtIndex(index int) *CommitFileNode
|
||||
Get(index int) *CommitFileNode
|
||||
GetFile(path string) *models.CommitFile
|
||||
GetAllItems() []*CommitFileNode
|
||||
GetAllFiles() []*models.CommitFile
|
||||
|
@ -42,7 +42,7 @@ func (self *CommitFileTree) ToggleShowTree() {
|
|||
self.SetTree()
|
||||
}
|
||||
|
||||
func (self *CommitFileTree) GetItemAtIndex(index int) *CommitFileNode {
|
||||
func (self *CommitFileTree) Get(index int) *CommitFileNode {
|
||||
// need to traverse the three depth first until we get to the index.
|
||||
return self.tree.GetNodeAtIndex(index+1, self.collapsedPaths) // ignoring root
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ func (self *CommitFileTree) GetAllItems() []*CommitFileNode {
|
|||
return self.tree.Flatten(self.collapsedPaths)[1:] // ignoring root
|
||||
}
|
||||
|
||||
func (self *CommitFileTree) GetItemsLength() int {
|
||||
func (self *CommitFileTree) Len() int {
|
||||
return self.tree.Size(self.collapsedPaths) - 1 // ignoring root
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue