main ece7682

render_divider_geometry_test.go RawHistoryFolder

1package daemon
2
3import (
4	"testing"
5
6	renderer "github.com/bnema/vev-vt"
7	"github.com/bnema/vev/internal/domain"
8	"github.com/bnema/vev/internal/domain/layout"
9	"github.com/stretchr/testify/require"
10)
11
12// TestComposeFrameDividerFollowsWeights proves rendered divider glyphs track
13// weight-aware pane geometry rather than an equal-split recomputation.
14func TestComposeFrameDividerFollowsWeights(t *testing.T) {
15	tests := []struct {
16		name                 string
17		direction            layout.SplitDir
18		area                 domain.Rect
19		glyph                rune
20		equalX, equalY       int
21		weightedX, weightedY int
22	}{
23		{
24			name:      "horizontal split",
25			direction: layout.Horizontal,
26			area:      domain.Rect{Width: 61, Height: 5},
27			glyph:     '│',
28			equalX:    30,
29			equalY:    1,
30			weightedX: 40,
31			weightedY: 1,
32		},
33		{
34			name:      "vertical split",
35			direction: layout.Vertical,
36			area:      domain.Rect{Width: 41, Height: 10},
37			glyph:     '─',
38			equalX:    1,
39			equalY:    6,
40			weightedX: 1,
41			weightedY: 7,
42		},
43	}
44
45	for _, tt := range tests {
46		t.Run(tt.name, func(t *testing.T) {
47			root := &layout.Node{Kind: layout.Split, Dir: tt.direction, Children: []*layout.Node{
48				{Kind: layout.Leaf, Leaf: "first", Weight: 1},
49				{Kind: layout.Leaf, Leaf: "second", Weight: 1},
50			}}
51			stateFor := func() capturedRenderState {
52				placements, dividers, ok := layout.SolveWithDividers(root, tt.area)
53				require.True(t, ok)
54				panes := make([]capturedPaneRenderState, 0, len(placements))
55				for _, placement := range placements {
56					frame := cachePaneFrame(placement.Content.Width, placement.Content.Height, rune(placement.ID[0]))
57					panes = append(panes, capturedPaneRenderState{
58						id: placement.ID, frame: frame, placement: placement, focused: placement.ID == "first",
59						damage: []renderer.Damage{renderer.FullRedraw()},
60					})
61				}
62				return capturedRenderState{
63					reset:  true,
64					layout: capturedTabLayout{area: tt.area, focus: "first", placements: placements, dividers: dividers, fingerprint: layoutFingerprint(root), valid: true},
65					panes:  panes, styles: resolveStyles(nil),
66				}
67			}
68
69			equal := stateFor()
70			out := composeFrame(equal, composeCacheInput{})
71			require.Equal(t, tt.glyph, out.frame.At(tt.equalX, tt.equalY).Rune, "equal weights must place the divider at the equal-split gap")
72
73			root.Children[0].Weight = 2
74			weighted := stateFor()
75			require.NotEqual(t, equal.layout.fingerprint, weighted.layout.fingerprint)
76
77			out = composeFrame(weighted, out.cache, composeCacheInput{})
78			require.Equal(t, tt.glyph, out.frame.At(tt.weightedX, tt.weightedY).Rune, "the divider must follow the weight-derived gap")
79			require.NotEqual(t, tt.glyph, out.frame.At(tt.equalX, tt.equalY).Rune, "the divider must not linger at the old equal-split gap")
80		})
81	}
82}
83
84// TestComposeFrameClearsCellsOutsideSharedLayout pins that a window larger
85// than the shared session layout blanks the cells the layout no longer covers
86// instead of keeping a wider earlier layout's cells on screen.
87func TestComposeFrameClearsCellsOutsideSharedLayout(t *testing.T) {
88	tests := []struct {
89		name       string
90		wide, next domain.Rect
91		x, y       int // stale content cell outside next, frame coordinates
92	}{
93		{name: "narrower layout clears the right side", wide: domain.Rect{Width: 6, Height: 2}, next: domain.Rect{Width: 4, Height: 2}, x: 5, y: 1},
94		{name: "shorter layout clears the bottom rows", wide: domain.Rect{Width: 6, Height: 2}, next: domain.Rect{Width: 6, Height: 1}, x: 0, y: 2},
95	}
96	for _, tt := range tests {
97		t.Run(tt.name, func(t *testing.T) {
98			stateFor := func(area domain.Rect, fingerprint string) capturedRenderState {
99				pane := renderer.NewFrame(area.Width, area.Height)
100				for y := range area.Height {
101					for x := range area.Width {
102						pane.Set(x, y, renderer.Cell{Rune: 'X', Style: renderer.DefaultStyle()})
103					}
104				}
105				placement := layout.Placement{ID: "p", Content: area}
106				return capturedRenderState{
107					window: domain.Size{Cols: 6, Rows: 2 + tabChromeRows},
108					layout: capturedTabLayout{area: area, focus: "p", valid: true, fingerprint: fingerprint, placements: []layout.Placement{placement}},
109					panes:  []capturedPaneRenderState{{id: "p", frame: pane, focused: true, placement: placement, damage: []renderer.Damage{renderer.FullRedraw()}}},
110				}
111			}
112			committed := composeFrame(stateFor(tt.wide, "wide"), composeCacheInput{})
113			require.Equal(t, 'X', committed.frame.At(tt.x, tt.y).Rune)
114
115			out := composeFrame(stateFor(tt.next, "next"), committed.cache, composeCacheInput{})
116			require.Equal(t, ' ', out.frame.At(tt.x, tt.y).Rune, "cell outside the shared layout must be blanked")
117		})
118	}
119}

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 12

Tags 11

↑↓ moveenter openesc close