summaryrefslogtreecommitdiffstats
path: root/pkg/gui/presentation
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2021-03-20 13:49:43 +1100
committerJesse Duffield <jessedduffield@gmail.com>2021-03-30 21:57:00 +1100
commitc27cea6f30c35328a24bb4fb7db4f002ab544ad3 (patch)
treeef9f74c757d80651e4229266f54918915478febd /pkg/gui/presentation
parentcd0532b4d6e9dcb846c6ce5ad88be7e0cf671a40 (diff)
more file tree improvements
Diffstat (limited to 'pkg/gui/presentation')
-rw-r--r--pkg/gui/presentation/files.go42
1 files changed, 25 insertions, 17 deletions
diff --git a/pkg/gui/presentation/files.go b/pkg/gui/presentation/files.go
index d64437b2c..900a5cabe 100644
--- a/pkg/gui/presentation/files.go
+++ b/pkg/gui/presentation/files.go
@@ -19,45 +19,53 @@ func GetFileListDisplayStrings(files []*models.File, diffName string, submoduleC
// getFileDisplayStrings returns the display string of branch
func getFileDisplayStrings(f *models.File, diffName string, submoduleConfigs []*models.SubmoduleConfig) []string {
- output := GetStatusNodeLine(f.HasUnstagedChanges, f.ShortStatus, f.Name, diffName, submoduleConfigs, f)
+ output := GetStatusNodeLine(f.HasUnstagedChanges, f.HasStagedChanges, f.Name, diffName, submoduleConfigs, f)
return []string{output}
}
-func GetStatusNodeLine(hasUnstagedChanges bool, shortStatus string, name string, diffName string, submoduleConfigs []*models.SubmoduleConfig, file *models.File) string {
+func GetStatusNodeLine(hasUnstagedChanges bool, hasStagedChanges bool, name string, diffName string, submoduleConfigs []*models.SubmoduleConfig, file *models.File) string {
// potentially inefficient to be instantiating these color
// objects with each render
red := color.New(color.FgRed)
green := color.New(color.FgGreen)
diffColor := color.New(theme.DiffTerminalColor)
+ partiallyModifiedColor := color.New(color.FgYellow)
var restColor *color.Color
if name == diffName {
restColor = diffColor
+ } else if file == nil && hasStagedChanges && hasUnstagedChanges {
+ restColor = partiallyModifiedColor
} else if hasUnstagedChanges {
restColor = red
} else {
restColor = green
}
- // this is just making things look nice when the background attribute is 'reverse'
- firstChar := shortStatus[0:1]
- firstCharCl := green
- if firstChar == "?" {
- firstCharCl = red
- } else if firstChar == " " {
- firstCharCl = restColor
- }
+ output := ""
+ if file != nil {
+ // this is just making things look nice when the background attribute is 'reverse'
+ firstChar := file.ShortStatus[0:1]
+ firstCharCl := green
+ if firstChar == "?" {
+ firstCharCl = red
+ } else if firstChar == " " {
+ firstCharCl = restColor
+ }
+
+ secondChar := file.ShortStatus[1:2]
+ secondCharCl := red
+ if secondChar == " " {
+ secondCharCl = restColor
+ }
- secondChar := shortStatus[1:2]
- secondCharCl := red
- if secondChar == " " {
- secondCharCl = restColor
+ output = firstCharCl.Sprint(firstChar)
+ output += secondCharCl.Sprint(secondChar)
+ output += " "
}
- output := firstCharCl.Sprint(firstChar)
- output += secondCharCl.Sprint(secondChar)
- output += restColor.Sprintf(" %s", name)
+ output += restColor.Sprint(name)
if file != nil && file.IsSubmodule(submoduleConfigs) {
output += utils.ColoredString(" (submodule)", theme.DefaultTextColor)