mirror of
https://github.com/docker/compose.git
synced 2026-11-17 21:57:19 +00:00
fix(display): clip the header line to the terminal width like every other row
The "[+] op N/M" header was the one line bypassing renderSegs, so on a very narrow terminal it could wrap and desync the cursor arithmetic the rest of the design guarantees against. Route it through the same clip and cover degenerate widths (8, 12 cells) in the invariant test. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
9fc38cce0e
commit
136763181b
2 changed files with 5 additions and 2 deletions
|
|
@ -65,7 +65,8 @@ const (
|
|||
// layoutFrame renders the whole progress block, one string per terminal row.
|
||||
func layoutFrame(t *taskTree, operation string, o layoutOpts) []string {
|
||||
done, total := t.counts()
|
||||
lines := []string{fmt.Sprintf("[+] %s %d/%d", operation, done, total)}
|
||||
header := fmt.Sprintf("[+] %s %d/%d", operation, done, total)
|
||||
lines := []string{renderSegs([]seg{{text: header}}, o.width)}
|
||||
|
||||
rows := buildRows(t, o)
|
||||
maxRows := max(o.height-2, 1)
|
||||
|
|
|
|||
|
|
@ -116,7 +116,9 @@ func adversarialEvents() []api.Resource {
|
|||
}
|
||||
|
||||
func TestTerm_NoLineEverExceedsTerminalWidth(t *testing.T) {
|
||||
for _, width := range []int{20, 30, 40, 60, 80, 120} {
|
||||
// 8 and 12 exercise the degenerate widths where even the "[+] op N/M"
|
||||
// header must be clipped rather than allowed to wrap
|
||||
for _, width := range []int{8, 12, 20, 30, 40, 60, 80, 120} {
|
||||
t.Run(fmt.Sprintf("width=%d", width), func(t *testing.T) {
|
||||
w, buf, _ := newTermWriter(width, 40)
|
||||
feed(w, adversarialEvents()...)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue