keyboard_test.go RawHistoryFolder

1package core
2
3import "testing"
4
5func TestKeyboardFocusOrder(t *testing.T) {
6	a := &screen{}
7	windows := map[*screen]WindowID{a: 1}
8	shown := true
9	cand := keyboardCandidates{window: 1, layerShown: func(WindowID) bool { return shown }, windows: func() map[*screen]WindowID { return windows }}
10	var k keyboard
11	if got := k.focus(cand); got != 1 {
12		t.Fatalf("focus = %d, want the window", got)
13	}
14	if !k.clickLayer(5, map[*screen]WindowID{a: 1}) || k.clickLayer(5, windows) {
15		t.Fatal("clickLayer change report")
16	}
17	if got := k.focus(cand); got != 5 {
18		t.Fatalf("focus = %d, want the clicked layer", got)
19	}
20	grab := cand
21	grab.grab = 7
22	if got := k.focus(grab); got != 7 {
23		t.Fatalf("focus = %d, want the grabbing popup", got)
24	}
25	grab.exclusive = 9
26	if got := k.focus(grab); got != 9 {
27		t.Fatalf("focus = %d, want the exclusive layer", got)
28	}
29	// The grab closed: the clicked layer still holds the keyboard.
30	if got := k.focus(cand); got != 5 {
31		t.Fatalf("focus = %d, want the clicked layer back", got)
32	}
33	// A window focus change on any output takes it back for good.
34	windows = map[*screen]WindowID{a: 2}
35	cand.window = 2
36	if got := k.focus(cand); got != 2 {
37		t.Fatalf("focus = %d, want the new window", got)
38	}
39	windows = map[*screen]WindowID{a: 1}
40	cand.window = 1
41	if got := k.focus(cand); got != 1 || k.layer != 0 {
42		t.Fatalf("focus = %d, layer %d; the layer must not come back", got, k.layer)
43	}
44}
45
46func TestKeyboardHiddenLayerLosesFocus(t *testing.T) {
47	windows := map[*screen]WindowID{}
48	shown := false
49	cand := keyboardCandidates{window: 1, layerShown: func(WindowID) bool { return shown }, windows: func() map[*screen]WindowID { return windows }}
50	var k keyboard
51	k.clickLayer(5, map[*screen]WindowID{})
52	if got := k.focus(cand); got != 1 {
53		t.Fatalf("focus = %d, want the window", got)
54	}
55	shown = true
56	if got := k.focus(cand); got != 1 {
57		t.Fatalf("focus = %d, the hidden layer must not come back", got)
58	}
59	k.clickLayer(5, map[*screen]WindowID{})
60	k.takeBack()
61	if got := k.focus(cand); got != 1 {
62		t.Fatalf("focus = %d after takeBack", got)
63	}
64}
65
66func TestKeyboardInhibit(t *testing.T) {
67	var k keyboard
68	if _, _, changed := k.inhibit(1, false); changed {
69		t.Fatal("no inhibitor changed")
70	}
71	if rel, act, changed := k.inhibit(1, true); rel != 0 || act != 1 || !changed || !k.inhibited(1) {
72		t.Fatalf("activate = %d, %d, %v", rel, act, changed)
73	}
74	if _, _, changed := k.inhibit(1, true); changed {
75		t.Fatal("same inhibitor changed")
76	}
77	if rel, act, changed := k.inhibit(2, true); rel != 1 || act != 2 || !changed {
78		t.Fatalf("switch = %d, %d, %v", rel, act, changed)
79	}
80	if rel, act, changed := k.inhibit(0, true); rel != 2 || act != 0 || !changed || k.inhibited(0) {
81		t.Fatalf("release = %d, %d, %v", rel, act, changed)
82	}
83}

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