From 26f5f383ce6885e97bc3d10eabd50e452e9f073a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lilian=20J=C3=B3nsd=C3=B3ttir?= Date: Mon, 15 Jul 2024 15:58:57 -0700 Subject: [PATCH] don't replace workdir anymore --- internal/dirs/dirs.go | 4 +--- internal/tables/tables.go | 10 +++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/internal/dirs/dirs.go b/internal/dirs/dirs.go index 5e721eb..9ef7ff7 100644 --- a/internal/dirs/dirs.go +++ b/internal/dirs/dirs.go @@ -11,14 +11,12 @@ import ( // $HOME -> ~ // $PWD -> . // workdir -> . -func UnExpand(dir, workdir string) (outdir string) { +func UnExpand(dir string) (outdir string) { outdir = filepath.Clean(dir) home := os.Getenv("HOME") if pwd, err := os.Getwd(); err == nil && home != pwd { outdir = strings.Replace(outdir, pwd, ".", 1) - } else if workdir != "" { - outdir = strings.Replace(outdir, workdir, "", 1) } outdir = strings.Replace(outdir, home, "~", 1) diff --git a/internal/tables/tables.go b/internal/tables/tables.go index 4243681..e4aec7f 100644 --- a/internal/tables/tables.go +++ b/internal/tables/tables.go @@ -279,7 +279,7 @@ func (m model) header() string { default: mode = m.mode.String() if m.workdir != "" { - mode += fmt.Sprintf(" in %s ", dirs.UnExpand(m.workdir, "")) + mode += fmt.Sprintf(" in %s ", dirs.UnExpand(m.workdir)) } } mode += fmt.Sprintf(" %s %s", dot, strings.Join(select_keys, wide_dot)) @@ -319,7 +319,7 @@ func (m model) selectedFiles() (outfile files.Files) { return false } */ -func newRow(file files.File, workdir string) table.Row { +func newRow(file files.File) table.Row { var t, b string t = humanize.Time(file.Date()) if file.IsDir() { @@ -329,7 +329,7 @@ func newRow(file files.File, workdir string) table.Row { } return table.Row{ dirs.UnEscape(file.Name()), - dirs.UnExpand(filepath.Dir(file.Path()), workdir), + dirs.UnExpand(filepath.Dir(file.Path())), t, b, } @@ -337,7 +337,7 @@ func newRow(file files.File, workdir string) table.Row { func (m *model) freshRows(preselected bool) (rows []table.Row) { for _, f := range m.files { - r := newRow(f, m.workdir) + r := newRow(f) if !m.readonly { r = append(r, getCheck(preselected)) @@ -474,7 +474,7 @@ func (m *model) sort() { slices.SortStableFunc(m.files, m.sorting.Sorter()) var rows []table.Row for _, file := range m.files { - r := newRow(file, m.workdir) + r := newRow(file) if !m.readonly { r = append(r, getCheck(m.selected[file.String()])) }