fix: lazysecrets list keeps the provider icon on error lines
This commit is contained in:
3 files changed
+9
-13
No files matched your search
@@ -34,7 +34,7 @@ import (
|
||||
//
|
||||
// What's cached prints at once; what's missing or older than --max-age
|
||||
// follows as it loads. A list that can't be read is a line too, as it
|
||||
// fails: ✗, the vault or source, and why, in the theme's error colour.
|
||||
// fails: the vault or source, then ✗ and why in the theme's error colour.
|
||||
// They're in the output rather than on stderr, which would draw over fzf.
|
||||
func listCmd(providers []provider.Provider, cachePath string, timeout func(provider.Kind) time.Duration, theme styles.Styles, withIcons bool, args []string, out io.Writer) error {
|
||||
fs := flag.NewFlagSet("list", flag.ContinueOnError)
|
||||
@@ -126,7 +126,7 @@ var oneLine = strings.NewReplacer("\t", " ", "\r\n", " ", "\n", " ", "\r", " ")
|
||||
|
||||
// nameOf is an entry's name for the text format: the provider's icon,
|
||||
// the path with the item's own name standing out, and the account. A
|
||||
// list that couldn't be read has ✗ for the icon, and why after it.
|
||||
// list that couldn't be read has ✗ and why after it.
|
||||
func nameOf(e listing.Entry, theme styles.Styles, iconSet icons.Set, color bool) string {
|
||||
render := func(st lipgloss.Style, s string) string {
|
||||
if !color || s == "" {
|
||||
@@ -141,10 +141,6 @@ func nameOf(e listing.Entry, theme styles.Styles, iconSet icons.Set, color bool)
|
||||
}
|
||||
}
|
||||
icon := iconSet.Prefix(kind)
|
||||
iconStyle := theme.Kind(kind)
|
||||
if e.Error != "" {
|
||||
icon, iconStyle = "✗ ", theme.Error
|
||||
}
|
||||
var name string
|
||||
if n := len(e.Path); n > 0 {
|
||||
if n > 1 {
|
||||
@@ -156,7 +152,7 @@ func nameOf(e listing.Entry, theme styles.Styles, iconSet icons.Set, color bool)
|
||||
name += render(theme.Muted, " · "+e.Account)
|
||||
}
|
||||
if e.Error != "" {
|
||||
name += " " + render(theme.Error, e.Error)
|
||||
name += " " + render(theme.Error, "✗ "+e.Error)
|
||||
}
|
||||
return render(iconStyle, strings.TrimSuffix(icon, " ")) + strings.Repeat(" ", min(len(icon), 1)) + name
|
||||
return render(theme.Kind(kind), strings.TrimSuffix(icon, " ")) + strings.Repeat(" ", min(len(icon), 1)) + name
|
||||
}
|
||||
Reference in new issue
Block a user