detached 25daf38

test(layout): cover cascade band widths with gaps and partial bands

commit
25daf386597ddd0c5b32ab8bb8027956a1994364
author
brice · · 2026-10-07 14:38 UTC
parent
7d82780
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +28 -0
M internal/core/cascade_test.go +21 -0
@@ -14,6 +14,27 @@ func cascadeWorkspace(n int) *Workspace {
1414 return w
1515 }
1616
17+// With gaps and a width that does not divide evenly, the columns of a
18+// partial band share what the gaps leave, and the configured width follows
19+// the band as it fills.
20+func TestCascadeBandWidthWithGaps(t *testing.T) {
21+ w := &Workspace{Overflow: OverflowCascade, MaxColumns: 3}
22+ w.SetOutput(1000, 600)
23+ w.SetGaps(8)
24+ w.AddWindow(1)
25+ if got := w.columnWidth(0); got != 1000-2*8 {
26+ t.Fatalf("lone column width %d, want %d", got, 1000-2*8)
27+ }
28+ w.AddWindow(2)
29+ cell := (1000 - 3*8) / 2
30+ for i, x := range []int{8, 8 + cell + 8} {
31+ r := w.columnRectsFor(false)[i]
32+ if r.X != x || r.W != cell || w.columnWidth(i) != cell {
33+ t.Fatalf("column %d rect %v width %d, want X %d W %d", i, r, w.columnWidth(i), x, cell)
34+ }
35+ }
36+}
37+
1738 // Each band's columns share its width equally, as in fixed overflow: a
1839 // lone column fills it, a full band of three has thirds.
1940 func TestCascadeBandsAndReveal(t *testing.T) {
@@ -14,6 +14,27 @@ func cascadeWorkspace(n int) *Workspace {
14 return w14 return w
15 }15 }
16 16
17+// With gaps and a width that does not divide evenly, the columns of a
18+// partial band share what the gaps leave, and the configured width follows
19+// the band as it fills.
20+func TestCascadeBandWidthWithGaps(t *testing.T) {
21+ w := &Workspace{Overflow: OverflowCascade, MaxColumns: 3}
22+ w.SetOutput(1000, 600)
23+ w.SetGaps(8)
24+ w.AddWindow(1)
25+ if got := w.columnWidth(0); got != 1000-2*8 {
26+ t.Fatalf("lone column width %d, want %d", got, 1000-2*8)
27+ }
28+ w.AddWindow(2)
29+ cell := (1000 - 3*8) / 2
30+ for i, x := range []int{8, 8 + cell + 8} {
31+ r := w.columnRectsFor(false)[i]
32+ if r.X != x || r.W != cell || w.columnWidth(i) != cell {
33+ t.Fatalf("column %d rect %v width %d, want X %d W %d", i, r, w.columnWidth(i), x, cell)
34+ }
35+ }
36+}
37+
17 // Each band's columns share its width equally, as in fixed overflow: a38 // Each band's columns share its width equally, as in fixed overflow: a
18 // lone column fills it, a full band of three has thirds.39 // lone column fills it, a full band of three has thirds.
19 func TestCascadeBandsAndReveal(t *testing.T) {40 func TestCascadeBandsAndReveal(t *testing.T) {
M internal/core/overview_cascade_test.go +7 -0
@@ -90,6 +90,9 @@ func TestOverviewCascadeMaximizedColumnCards(t *testing.T) {
9090 {n: 4, max: 0, cards: []int{0, 1, 2, 0}, order: []int{2, 1, 0}},
9191 {n: 4, max: 1, cards: []int{-1, 0, 1, 0}, order: []int{0, 2, 1}},
9292 {n: 4, max: 3, cards: []int{0, 0, 0, 0}},
93+ // Partial bands: the card has its band's half width.
94+ {n: 2, max: 0, cards: []int{0, 1}, order: []int{1, 0}},
95+ {n: 5, max: 4, cards: []int{0, 0, 0, -1, 0}},
9396 } {
9497 w := cascadeWorkspace(tc.n)
9598 w.Focus = tc.max
@@ -119,6 +122,10 @@ func TestOverviewCascadeMaximizedColumnCards(t *testing.T) {
119122 if p.Hidden || p.Peek != (tc.cards[i] != 0) || p.Focused != (i == tc.max) || p.Rect != want {
120123 t.Fatalf("n=%d max=%d column %d: %+v, want rect %+v card %v", tc.n, tc.max, i, p, want, tc.cards[i] != 0)
121124 }
125+ // The 900-wide band split among its columns, no gaps.
126+ if inBand := min(tc.n-band*3, 3); i != tc.max && p.Rect.W != 900/inBand {
127+ t.Fatalf("n=%d max=%d column %d width %d, want %d", tc.n, tc.max, i, p.Rect.W, 900/inBand)
128+ }
122129 if i == tc.max && sel != want {
123130 t.Fatalf("n=%d max=%d sel %+v, want %+v", tc.n, tc.max, sel, want)
124131 }
@@ -90,6 +90,9 @@ func TestOverviewCascadeMaximizedColumnCards(t *testing.T) {
90 {n: 4, max: 0, cards: []int{0, 1, 2, 0}, order: []int{2, 1, 0}},90 {n: 4, max: 0, cards: []int{0, 1, 2, 0}, order: []int{2, 1, 0}},
91 {n: 4, max: 1, cards: []int{-1, 0, 1, 0}, order: []int{0, 2, 1}},91 {n: 4, max: 1, cards: []int{-1, 0, 1, 0}, order: []int{0, 2, 1}},
92 {n: 4, max: 3, cards: []int{0, 0, 0, 0}},92 {n: 4, max: 3, cards: []int{0, 0, 0, 0}},
93+ // Partial bands: the card has its band's half width.
94+ {n: 2, max: 0, cards: []int{0, 1}, order: []int{1, 0}},
95+ {n: 5, max: 4, cards: []int{0, 0, 0, -1, 0}},
93 } {96 } {
94 w := cascadeWorkspace(tc.n)97 w := cascadeWorkspace(tc.n)
95 w.Focus = tc.max98 w.Focus = tc.max
@@ -119,6 +122,10 @@ func TestOverviewCascadeMaximizedColumnCards(t *testing.T) {
119 if p.Hidden || p.Peek != (tc.cards[i] != 0) || p.Focused != (i == tc.max) || p.Rect != want {122 if p.Hidden || p.Peek != (tc.cards[i] != 0) || p.Focused != (i == tc.max) || p.Rect != want {
120 t.Fatalf("n=%d max=%d column %d: %+v, want rect %+v card %v", tc.n, tc.max, i, p, want, tc.cards[i] != 0)123 t.Fatalf("n=%d max=%d column %d: %+v, want rect %+v card %v", tc.n, tc.max, i, p, want, tc.cards[i] != 0)
121 }124 }
125+ // The 900-wide band split among its columns, no gaps.
126+ if inBand := min(tc.n-band*3, 3); i != tc.max && p.Rect.W != 900/inBand {
127+ t.Fatalf("n=%d max=%d column %d width %d, want %d", tc.n, tc.max, i, p.Rect.W, 900/inBand)
128+ }
122 if i == tc.max && sel != want {129 if i == tc.max && sel != want {
123 t.Fatalf("n=%d max=%d sel %+v, want %+v", tc.n, tc.max, sel, want)130 t.Fatalf("n=%d max=%d sel %+v, want %+v", tc.n, tc.max, sel, want)
124 }131 }

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 23

Tags 10

↑↓ moveenter openesc close