Fix spacing for empty custom info (#2208)
This commit is contained in:
1 parent
f74cf581b3
commit
06376f9089
2 files changed
+8
-1
No files matched your search
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user