Compare commits

..

2 Commits

Author SHA1 Message Date
3247a5aae3 Merge pull request #6675 from vvoland/img-list-noellipsis
Some checks failed
build / prepare-plugins (push) Has been cancelled
build / plugins (push) Has been cancelled
codeql / codeql (push) Has been cancelled
e2e / tests (alpine, 25, connhelper-ssh) (push) Has been cancelled
e2e / tests (alpine, 25, local) (push) Has been cancelled
e2e / tests (alpine, 27, connhelper-ssh) (push) Has been cancelled
e2e / tests (alpine, 27, local) (push) Has been cancelled
e2e / tests (alpine, 28, connhelper-ssh) (push) Has been cancelled
e2e / tests (alpine, 28, local) (push) Has been cancelled
e2e / tests (alpine, 29-rc, connhelper-ssh) (push) Has been cancelled
e2e / tests (alpine, 29-rc, local) (push) Has been cancelled
e2e / tests (debian, 25, connhelper-ssh) (push) Has been cancelled
e2e / tests (debian, 25, local) (push) Has been cancelled
e2e / tests (debian, 27, connhelper-ssh) (push) Has been cancelled
e2e / tests (debian, 27, local) (push) Has been cancelled
e2e / tests (debian, 28, connhelper-ssh) (push) Has been cancelled
e2e / tests (debian, 28, local) (push) Has been cancelled
e2e / tests (debian, 29-rc, connhelper-ssh) (push) Has been cancelled
e2e / tests (debian, 29-rc, local) (push) Has been cancelled
test / ctn (push) Has been cancelled
test / host (macos-14) (push) Has been cancelled
test / host (macos-15) (push) Has been cancelled
test / host (macos-15-intel) (push) Has been cancelled
validate / validate (lint) (push) Has been cancelled
validate / validate (shellcheck) (push) Has been cancelled
validate / validate (update-authors) (push) Has been cancelled
validate / validate (validate-vendor) (push) Has been cancelled
validate / validate-md (push) Has been cancelled
validate / validate-make (manpages) (push) Has been cancelled
validate / validate-make (yamldocs) (push) Has been cancelled
image/tree: Allow image names to overflow instead of truncating
2025-11-24 21:35:37 +00:00
4759615835 image/tree: Allow image names to overflow instead of truncating
Users were experiencing poor UX when image names were truncated in the
table output.

Instead of cutting off long image names with ellipsis, the names now
wrap to the next line to ensure full visibility.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-11-24 22:12:37 +01:00

View File

@ -258,9 +258,10 @@ func printImageTree(outs command.Streams, view treeView) {
possibleChips := getPossibleChips(view)
columns := []imgColumn{
{
Title: "Image",
Align: alignLeft,
Width: 0,
Title: "Image",
Align: alignLeft,
Width: 0,
NoEllipsis: true,
},
{
Title: "ID",
@ -436,13 +437,27 @@ func printNames(out tui.Output, headers []imgColumn, img topImage, color, untagg
}
for nameIdx, name := range img.Names {
// Don't limit first names to the column width because only the last
// name will be printed alongside other columns.
if nameIdx < len(img.Names)-1 {
_, fullWidth := out.GetTtySize()
_, _ = fmt.Fprintln(out, color.Apply(tui.Ellipsis(name, int(fullWidth))))
} else {
_, _ = fmt.Fprint(out, headers[0].Print(color, name))
nameWidth := tui.Width(name)
lastName := nameIdx == len(img.Names)-1
multiLine := nameWidth > headers[0].Width
_, _ = fmt.Fprint(out, headers[0].Print(color, name))
// Print each name on its own line, including the last,
// unless the last name fits into the column.
//
// IMAGE ID ...
// anImage 171e65262c80 ...
// firstName
// lastNameIsALongOne
// eade5be814e8 ...
// anotherLongName
// bb747ca923a5 ...
if !lastName || multiLine {
_, _ = fmt.Fprintln(out)
}
if multiLine && lastName {
_, _ = fmt.Fprint(out, strings.Repeat(" ", headers[0].Width))
}
}
}
@ -462,6 +477,7 @@ type imgColumn struct {
DetailsValue func(*imageDetails) string
Color *aec.ANSI
NoEllipsis bool
}
func (h imgColumn) Print(clr aec.ANSI, s string) string {
@ -478,12 +494,16 @@ func (h imgColumn) Print(clr aec.ANSI, s string) string {
func (h imgColumn) PrintC(clr aec.ANSI, s string) string {
ln := tui.Width(s)
if ln > h.Width {
return clr.Apply(tui.Ellipsis(s, h.Width))
}
fill := h.Width - ln
if fill < 0 {
if h.NoEllipsis {
fill = 0
} else {
return clr.Apply(tui.Ellipsis(s, h.Width))
}
}
l := fill / 2
r := fill - l
@ -492,20 +512,33 @@ func (h imgColumn) PrintC(clr aec.ANSI, s string) string {
func (h imgColumn) PrintL(clr aec.ANSI, s string) string {
ln := tui.Width(s)
if ln > h.Width {
return clr.Apply(tui.Ellipsis(s, h.Width))
fill := h.Width - ln
if fill < 0 {
if h.NoEllipsis {
fill = 0
} else {
return clr.Apply(tui.Ellipsis(s, h.Width))
}
}
return clr.Apply(s) + strings.Repeat(" ", h.Width-ln)
return clr.Apply(s) + strings.Repeat(" ", fill)
}
func (h imgColumn) PrintR(clr aec.ANSI, s string) string {
ln := tui.Width(s)
if ln > h.Width {
return clr.Apply(tui.Ellipsis(s, h.Width))
fill := h.Width - ln
if fill < 0 {
if h.NoEllipsis {
fill = 0
} else {
return clr.Apply(tui.Ellipsis(s, h.Width))
}
}
return strings.Repeat(" ", h.Width-ln) + clr.Apply(s)
return strings.Repeat(" ", fill) + clr.Apply(s)
}
// widestFirstColumnValue calculates the width needed to fully display the image names and platforms.