This commit is contained in:
Peter Cousins 2026-08-30 13:40:46 -07:00 committed by GitHub
commit 348ce04349
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 1 deletions

View file

@ -28,6 +28,9 @@ type ListContextTrait struct {
// true if we're inside the OnSearchSelect call; in that case we don't want to update the search
// result index.
inOnSearchSelect bool
// Optional function to append extra info to the footer (e.g. file count in tree view)
footerExtra func() string
}
func (self *ListContextTrait) IsListContext() {}
@ -81,7 +84,13 @@ func (self *ListContextTrait) refreshViewport() {
}
func (self *ListContextTrait) setFooter() {
self.GetViewTrait().SetFooter(formatListFooter(self.list.GetSelectedLineIdx(), self.list.Len()))
footer := formatListFooter(self.list.GetSelectedLineIdx(), self.list.Len())
if self.footerExtra != nil {
if extra := self.footerExtra(); extra != "" {
footer += " | " + extra
}
}
self.GetViewTrait().SetFooter(footer)
}
func formatListFooter(selectedLineIdx int, length int) string {

View file

@ -1,6 +1,8 @@
package context
import (
"fmt"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/gui/filetree"
"github.com/jesseduffield/lazygit/pkg/gui/presentation"
@ -50,6 +52,14 @@ func NewWorkingTreeContext(c *ContextCommon) *WorkingTreeContext {
getDisplayStrings: getDisplayStrings,
},
c: c,
footerExtra: func() string {
fileCount := len(viewModel.GetAllFiles())
label := "changes"
if fileCount == 1 {
label = "change"
}
return fmt.Sprintf("%d %s", fileCount, label)
},
},
}