mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-15 00:15:32 +02:00
Add user config gui.showNumstatInFilesView
When enabled, it adds "+n -m" after each file in the Files panel to show how many lines were added and deleted, as with `git diff --numstat` on the command line.
This commit is contained in:
committed by
Stefan Haller
parent
f3a5c184e1
commit
f455f99705
@ -22,12 +22,13 @@ func RenderFileTree(
|
||||
tree filetree.IFileTree,
|
||||
submoduleConfigs []*models.SubmoduleConfig,
|
||||
showFileIcons bool,
|
||||
showNumstat bool,
|
||||
) []string {
|
||||
collapsedPaths := tree.CollapsedPaths()
|
||||
return renderAux(tree.GetRoot().Raw(), collapsedPaths, -1, -1, func(node *filetree.Node[models.File], treeDepth int, visualDepth int, isCollapsed bool) string {
|
||||
fileNode := filetree.NewFileNode(node)
|
||||
|
||||
return getFileLine(isCollapsed, fileNode.GetHasUnstagedChanges(), fileNode.GetHasStagedChanges(), treeDepth, visualDepth, showFileIcons, submoduleConfigs, node)
|
||||
return getFileLine(isCollapsed, fileNode.GetHasUnstagedChanges(), fileNode.GetHasStagedChanges(), treeDepth, visualDepth, showNumstat, showFileIcons, submoduleConfigs, node)
|
||||
})
|
||||
}
|
||||
|
||||
@ -111,6 +112,7 @@ func getFileLine(
|
||||
hasStagedChanges bool,
|
||||
treeDepth int,
|
||||
visualDepth int,
|
||||
showNumstat,
|
||||
showFileIcons bool,
|
||||
submoduleConfigs []*models.SubmoduleConfig,
|
||||
node *filetree.Node[models.File],
|
||||
@ -165,6 +167,12 @@ func getFileLine(
|
||||
output += theme.DefaultTextColor.Sprint(" (submodule)")
|
||||
}
|
||||
|
||||
if file != nil && showNumstat {
|
||||
if lineChanges := formatLineChanges(file.LinesAdded, file.LinesDeleted); lineChanges != "" {
|
||||
output += " " + lineChanges
|
||||
}
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
@ -186,6 +194,23 @@ func formatFileStatus(file *models.File, restColor style.TextStyle) string {
|
||||
return firstCharCl.Sprint(firstChar) + secondCharCl.Sprint(secondChar)
|
||||
}
|
||||
|
||||
func formatLineChanges(linesAdded, linesDeleted int) string {
|
||||
output := ""
|
||||
|
||||
if linesAdded != 0 {
|
||||
output += style.FgGreen.Sprintf("+%d", linesAdded)
|
||||
}
|
||||
|
||||
if linesDeleted != 0 {
|
||||
if output != "" {
|
||||
output += " "
|
||||
}
|
||||
output += style.FgRed.Sprintf("-%d", linesDeleted)
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
func getCommitFileLine(
|
||||
isCollapsed bool,
|
||||
treeDepth int,
|
||||
|
Reference in New Issue
Block a user