From 3734989b1546c7107a425c4a1ddab0ea2029fab4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl-Einar=20Bergstr=C3=B8m?= Date: Wed, 14 Oct 2026 13:18:33 +0200 Subject: [PATCH] fix: lazysecrets list keeps the provider icon on error lines --- cmd/lazysecrets/list.go | 12 ++++-------- cmd/lazysecrets/list_test.go | 4 ++-- docs/links.md | 6 +++--- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/cmd/lazysecrets/list.go b/cmd/lazysecrets/list.go index 78bad5e..d7b0dc5 100644 --- a/cmd/lazysecrets/list.go +++ b/cmd/lazysecrets/list.go @@ -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 } diff --git a/cmd/lazysecrets/list_test.go b/cmd/lazysecrets/list_test.go index b823313..e6137fd 100644 --- a/cmd/lazysecrets/list_test.go +++ b/cmd/lazysecrets/list_test.go @@ -26,10 +26,10 @@ func TestListNames(t *testing.T) { func TestListErrorNames(t *testing.T) { e := listing.Entry{Provider: "azure", Path: []string{"platform-prod", "kv-restricted"}, Error: "403 Forbidden"} - if got := nameOf(e, styles.Default(), icons.NerdFont, false); got != "✗ platform-prod / kv-restricted 403 Forbidden" { + if got := nameOf(e, styles.Default(), icons.NerdFont, false); got != icons.NerdFont.Azure+" platform-prod / kv-restricted ✗ 403 Forbidden" { t.Errorf("plain: %q", got) } - red := styles.Default().Error.Render("403 Forbidden") + red := styles.Default().Error.Render("✗ 403 Forbidden") if got := nameOf(e, styles.Default(), icons.NerdFont, true); !strings.HasSuffix(got, red) { t.Errorf("why isn't in the error colour: %q", got) } diff --git a/docs/links.md b/docs/links.md index 7edbcdc..1c4e6e6 100644 --- a/docs/links.md +++ b/docs/links.md @@ -162,9 +162,9 @@ only other kinds need aren't loaded: `--kind source,vault` asks for no secrets. Keys and certificates load only when asked for this way; else, like Go to, they're listed as far as you opened them in lazysecrets. -A vault or source it can't read is a line too, as it fails: `✗`, its -name and why, in red (`errorColor`), with its link, so opening it shows -more. They're in the list, not on stderr, which would draw over fzf. +A vault or source it can't read is a line too, as it fails: its name, +then `✗` and why in red (`errorColor`), with its link, so opening it +shows more. They're in the list, not on stderr, which would draw over fzf. `--errors=false` leaves them out. The name is coloured from your [theme](config.md#theme), with the