commit 3a017757b6e880fb4b863f992151b745a9d157b0
parent 53d39543b3cee4c17ba904b72fe1a74b6cbfad5c
Author: Jack Mordaunt <jackmordaunt.dev@gmail.com>
Date: Wed, 16 Sep 2026 21:30:08 -0400
cmd/preview: fix save-as extension and icon list reset
UseExt ignored its argument and always produced .icns, and the icon list was
never cleared between files, so opening a second icns appended its sizes to
the first. Both were latent since the GUI was written.
Diffstat:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/cmd/preview/main.go b/cmd/preview/main.go
@@ -169,7 +169,7 @@ func (ui *UI) Update(gtx C) {
// TODO(jfm): push to dismissable error stack.
log.Printf("loading icns file: %v", r.Err)
} else {
- ui.Icons = ui.Icons[:]
+ ui.Icons = ui.Icons[:0]
for _, img := range r.Imgs {
ui.Icons = append(ui.Icons, widget.Image{
Src: paint.NewImageOp(img),
@@ -344,5 +344,5 @@ func LoadImage(path string) ([]image.Image, error) {
// UseExt replaces any existing file extension with the provided one.
func UseExt(s, ext string) string {
- return strings.Replace(s, filepath.Ext(s), ".icns", 1)
+ return strings.TrimSuffix(s, filepath.Ext(s)) + ext
}