v0.4.0 b6be3a8

overview_regression_test.go RawHistoryFolder

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

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