pane_test.go RawHistoryFolder

1package entity
2
3import "testing"
4
5func TestPaneNode_VisibleAreaCount(t *testing.T) {
6	tests := []struct {
7		name     string
8		node     *PaneNode
9		expected int
10	}{
11		{
12			name: "single leaf pane",
13			node: &PaneNode{
14				ID:   "pane1",
15				Pane: NewPane("pane1"),
16			},
17			expected: 1,
18		},
19		{
20			name: "horizontal split with two leaves",
21			node: &PaneNode{
22				ID:       "split1",
23				SplitDir: SplitHorizontal,
24				Children: []*PaneNode{
25					{ID: "pane1", Pane: NewPane("pane1")},
26					{ID: "pane2", Pane: NewPane("pane2")},
27				},
28			},
29			expected: 2,
30		},
31		{
32			name: "stacked panes count as one",
33			node: &PaneNode{
34				ID:               "stack1",
35				IsStacked:        true,
36				ActiveStackIndex: 0,
37				Children: []*PaneNode{
38					{ID: "pane1", Pane: NewPane("pane1")},
39					{ID: "pane2", Pane: NewPane("pane2")},
40					{ID: "pane3", Pane: NewPane("pane3")},
41				},
42			},
43			expected: 1,
44		},
45		{
46			name: "split with one stacked side",
47			node: &PaneNode{
48				ID:       "split1",
49				SplitDir: SplitHorizontal,
50				Children: []*PaneNode{
51					{ID: "pane1", Pane: NewPane("pane1")},
52					{
53						ID:               "stack1",
54						IsStacked:        true,
55						ActiveStackIndex: 0,
56						Children: []*PaneNode{
57							{ID: "pane2", Pane: NewPane("pane2")},
58							{ID: "pane3", Pane: NewPane("pane3")},
59						},
60					},
61				},
62			},
63			expected: 2,
64		},
65		{
66			name: "nested splits",
67			node: &PaneNode{
68				ID:       "split1",
69				SplitDir: SplitHorizontal,
70				Children: []*PaneNode{
71					{ID: "pane1", Pane: NewPane("pane1")},
72					{
73						ID:       "split2",
74						SplitDir: SplitVertical,
75						Children: []*PaneNode{
76							{ID: "pane2", Pane: NewPane("pane2")},
77							{ID: "pane3", Pane: NewPane("pane3")},
78						},
79					},
80				},
81			},
82			expected: 3,
83		},
84		{
85			name: "complex tree with stacks and splits",
86			node: &PaneNode{
87				ID:       "split1",
88				SplitDir: SplitHorizontal,
89				Children: []*PaneNode{
90					{
91						ID:               "stack1",
92						IsStacked:        true,
93						ActiveStackIndex: 0,
94						Children: []*PaneNode{
95							{ID: "pane1", Pane: NewPane("pane1")},
96							{ID: "pane2", Pane: NewPane("pane2")},
97						},
98					},
99					{
100						ID:       "split2",
101						SplitDir: SplitVertical,
102						Children: []*PaneNode{
103							{ID: "pane3", Pane: NewPane("pane3")},
104							{
105								ID:               "stack2",
106								IsStacked:        true,
107								ActiveStackIndex: 1,
108								Children: []*PaneNode{
109									{ID: "pane4", Pane: NewPane("pane4")},
110									{ID: "pane5", Pane: NewPane("pane5")},
111								},
112							},
113						},
114					},
115				},
116			},
117			expected: 3, // stack1(1) + pane3(1) + stack2(1)
118		},
119	}
120
121	for _, tt := range tests {
122		t.Run(tt.name, func(t *testing.T) {
123			got := tt.node.VisibleAreaCount()
124			if got != tt.expected {
125				t.Errorf("VisibleAreaCount() = %d, want %d", got, tt.expected)
126			}
127		})
128	}
129}

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 8

Tags 42

↑↓ moveenter openesc close