diff --git a/CHANGELOG.md b/CHANGELOG.md index 1989d007..36b05ad4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), - A bug where the copy progress indicator only displayed the first time a file was copied is now fixed (#2181). - A bug where the `source` command does not show an error message upon failure is now fixed (#2189). - The `addcustominfo` command now supports file completions (#2198). +- A bug where an empty `custom` info property would still take up space is now fixed (#2208). ## [r38](https://github.com/gokcehan/lf/releases/tag/r38) diff --git a/ui.go b/ui.go index 047c8634..db68f4a8 100644 --- a/ui.go +++ b/ui.go @@ -336,6 +336,10 @@ func fileInfo(f *file, d *dir, userWidth int, groupWidth int, customWidth int) ( case "group": fmt.Fprintf(&info, " %-*s", groupWidth, groupName(f.FileInfo)) case "custom": + // Prevent useless spacers, as `custom` allows empty values + if customWidth < 1 { + continue + } // To allow for the usage of escape sequences, store `custom` // separately and print it later using the offset. off = info.Len() @@ -413,6 +417,7 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty var userWidth int var groupWidth int var customWidth int + var fetchedCustom bool // Only fetch user/group/custom widths if configured to display them for _, s := range getInfo(dir.path) { @@ -423,9 +428,10 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty groupWidth = getGroupWidth(dir, beg, end) case "custom": customWidth = getCustomWidth(dir, beg, end) + fetchedCustom = true // Can have a length of 0 } - if userWidth > 0 && groupWidth > 0 && customWidth > 0 { + if userWidth > 0 && groupWidth > 0 && fetchedCustom { break } }