mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-03-17 21:18:31 +02:00
Ensure file view length is never returned as -1
This was causing issues when obtaining selected items
This commit is contained in:
parent
9bf3063457
commit
c07b3fad64
@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
"github.com/samber/lo"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
@ -138,7 +139,8 @@ func (self *FileTree) GetAllItems() []*FileNode {
|
||||
}
|
||||
|
||||
func (self *FileTree) Len() int {
|
||||
return self.tree.Size(self.collapsedPaths) - 1 // ignoring root
|
||||
// -1 because we're ignoring the root
|
||||
return utils.Max(self.tree.Size(self.collapsedPaths)-1, 0)
|
||||
}
|
||||
|
||||
func (self *FileTree) GetItem(index int) types.HasUrn {
|
||||
|
@ -54,6 +54,10 @@ func (self *FileTreeViewModel) GetSelectedItemId() string {
|
||||
}
|
||||
|
||||
func (self *FileTreeViewModel) GetSelectedItems() ([]*FileNode, int, int) {
|
||||
if self.Len() == 0 {
|
||||
return nil, 0, 0
|
||||
}
|
||||
|
||||
startIdx, endIdx := self.GetSelectionRange()
|
||||
|
||||
nodes := []*FileNode{}
|
||||
|
Loading…
x
Reference in New Issue
Block a user