overview_regression_test.go RawHistoryFolder

1package core
2
3import "testing"
4
5func TestOverviewLeaveStashThenVerticalSelectsFront(t *testing.T) {
6	for _, accept := range []bool{false, true} {
7		m := stackMonitor()
8		w := m.Current()
9		w.FocusID(1)
10		w.ToggleWindowStash()
11		w.FocusID(9)
12		m.ToggleOverview()
13		m.OverviewMove(-1, 0) // float to columns
14		m.OverviewMove(-1, 0) // first column to stash
15		if m.cardAt(w) < 0 {
16			t.Fatal("not in stash")
17		}
18		m.OverviewMove(1, 0) // leave stash before cycling the main stack
19		m.OverviewMove(0, 1)
20		p := previewOf(t, m.Layout(), 9)
21		if !p.Focused || p.Peek || m.cardAt(w) >= 0 {
22			t.Fatalf("vertical selection: %+v, stash %d", p, m.cardAt(w))
23		}
24		if e := m.Apply(ActionCloseWindow); e.Close != 9 {
25			t.Fatalf("close target %d, want 9", e.Close)
26		}
27		if accept {
28			m.ToggleOverview()
29			if id, _ := w.Focused(); id != 9 || !w.floatFocus {
30				t.Fatalf("accepted focus %d, stash hidden %v", id, w.stashHidden)
31			}
32		}
33	}
34}
35
36func TestOverviewSingleCoveringFloat(t *testing.T) {
37	for _, stash := range []bool{false, true} {
38		for _, neighbor := range []bool{false, true} {
39			for _, click := range []bool{false, true} {
40				m := monitor()
41				m.SetOutput(300, 200)
42				w := m.Current()
43				if stash {
44					w.AddWindow(1)
45					w.ToggleWindowStash()
46					w.ToggleStashVisible()
47				}
48				m.AddFloating(9, 300, 200)
49				if neighbor {
50					m.Focus(1)
51					m.AddFloating(8, 300, 200)
52					m.Focus(0)
53				}
54				m.ToggleOverview()
55				p := previewOf(t, m.Layout(), 9)
56				if p.Hidden || p.Preview <= 0 || p.Rect.W <= 0 || p.Rect.H <= 0 || !p.Focused {
57					t.Fatalf("single float preview %+v", p)
58				}
59				if neighbor {
60					q := previewOf(t, m.Layout(), 8)
61					if q.Hidden || q.Preview <= 0 || q.Focused || !q.Peek {
62						t.Fatalf("neighbor preview %+v", q)
63					}
64				}
65				if click {
66					id := overviewIn(m.Layout(), float64(p.Rect.X+p.Rect.W/2), float64(p.Rect.Y+p.Rect.H/2))
67					if id != 9 {
68						t.Fatalf("hit %d, want 9", id)
69					}
70					m.OverviewPick(id)
71				} else {
72					m.ToggleOverview()
73				}
74				if id, _ := w.Focused(); id != 9 || m.ov.open {
75					t.Fatalf("accepted focus %d, overview %v", id, m.ov.open)
76				}
77			}
78		}
79	}
80}
81
82func TestOverviewCloseTargetsFront(t *testing.T) {
83	m := stackMonitor()
84	m.ToggleOverview()
85	m.OverviewMove(0, -1)
86	if e := m.Apply(ActionCloseWindow); e.Close != 3 {
87		t.Fatalf("close target %d, want selected column 3", e.Close)
88	}
89}
90
91func TestOverviewTargetAfterUnmaximizeMutation(t *testing.T) {
92	for _, add := range []bool{false, true} {
93		m := maximizedOverview()
94		w := m.Current()
95		m.ToggleOverview()
96		m.OverviewMove(0, -1)
97		m.OverviewMove(1, 0)
98		if m.ov.selected != 3 {
99			t.Fatalf("setup selection %d, want 3", m.ov.selected)
100		}
101		if add {
102			w.AddWindow(7)
103		} else {
104			w.RemoveWindow(2)
105		}
106		var highlighted WindowID
107		for _, p := range m.Layout() {
108			if p.Focused && !p.Hidden {
109				if highlighted != 0 {
110					t.Fatal("multiple highlighted previews")
111				}
112				highlighted = p.ID
113			}
114		}
115		if highlighted == 0 || m.overviewTarget() != highlighted || m.Apply(ActionCloseWindow).Close != highlighted {
116			t.Fatalf("add %v: highlighted %d, target %d, close %d", add, highlighted, m.overviewTarget(), m.Apply(ActionCloseWindow).Close)
117		}
118		m.ToggleOverview()
119		if id, _ := w.Focused(); id != highlighted {
120			t.Fatalf("accepted %d, want highlighted %d", id, highlighted)
121		}
122	}
123}
124
125func TestOverviewWindowMutationsDisabled(t *testing.T) {
126	actions := []Action{
127		ActionMoveColumnLeft, ActionMoveColumnRight, ActionCycleColumnWidth,
128		ActionMaximizeColumn, ActionToggleFullscreen, ActionToggleWindowStash,
129		ActionToggleStashVisible, ActionConsumeOrExpelLeft,
130		ActionConsumeOrExpelRight, ActionMoveWorkspaceLeft, ActionMoveWorkspaceRight,
131		ActionMoveWorkspaceToMonitorUp, ActionMoveWorkspaceToMonitorDown,
132	}
133	for _, a := range actions {
134		t.Run(string(a), func(t *testing.T) {
135			m := stackMonitor()
136			m.ToggleOverview()
137			m.OverviewMove(0, -1)
138			before := m.Layout()
139			m.Apply(a)
140			after := m.Layout()
141			if len(before) != len(after) {
142				t.Fatalf("layout length changed: %d -> %d", len(before), len(after))
143			}
144			for i := range before {
145				if before[i] != after[i] {
146					t.Fatalf("layout changed: %+v -> %+v", before[i], after[i])
147				}
148			}
149		})
150	}
151}

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 25

Tags 10

↑↓ moveenter openesc close