v0.4.0 b6be3a8

animate_alloc_test.go RawHistoryFolder

1package core
2
3import (
4	"testing"
5	"time"
6)
7
8// TestAnimateAllocations guards animate: with a camera, a switch and 20 rect
9// motions running (fade, dim and scale components, half of them leaving) it
10// allocates nothing.
11func TestAnimateAllocations(t *testing.T) {
12	c, ic := indicatorCore(t)
13	c.cfg.Animations.On = true
14	sc := c.cur()
15	t0 := ic.now
16	m := sc.mon
17	m.AddWindow(1)
18	m.AddWindow(2)
19
20	ws := m.Workspaces[0]
21	ws.motion = c.spring(viewSpring(100, 0), t0)
22	ws.shift = 100
23	m.switchMotion = c.spring(workspaceSpring(100, 0), t0)
24	m.switchOff = 100
25	sc.rects = make(map[WindowID]rectMotion, 20)
26	for i := range 20 {
27		sp := viewSpring(50, 0)
28		rm := rectMotion{
29			x: c.spring(sp, t0), y: c.spring(sp, t0),
30			w: c.spring(sp, t0), h: c.spring(sp, t0),
31			dx: 50, dy: 50, dw: 50, dh: 50,
32			fade: c.spring(levelSpring(1, 0), t0), df: 1,
33			dim: c.spring(levelSpring(0.5, 0), t0), ddim: 0.5,
34			scale: true,
35		}
36		if i%2 == 0 {
37			rm.leaving, rm.left = true, Placement{ID: WindowID(100 + i), Rect: Rect{W: 10, H: 10}}
38		}
39		sc.rects[WindowID(100+i)] = rm
40	}
41
42	// A stash peek's veil moves alone (a navigation): dim-only motions,
43	// some going below zero, as an offset from Stash.Dim.
44	for i := range 4 {
45		var rm rectMotion
46		from := 0.5
47		if i%2 == 1 {
48			from = -0.5
49		}
50		rm.dim, rm.ddim = c.spring(levelSpring(from, 0), t0), from
51		sc.rects[WindowID(200+i)] = rm
52	}
53
54	now := t0.Add(10 * time.Millisecond)
55	for name, only := range map[string]*screen{"all": nil, "only": sc} {
56		if n := testing.AllocsPerRun(100, func() { c.animate(now, only) }); n != 0 {
57			t.Errorf("animate(%s) allocs = %v, want 0", name, n)
58		}
59	}
60	if !ws.motion.on || !m.switchMotion.on || len(sc.rects) != 24 {
61		t.Fatalf("motions settled: camera %v switch %v rects %d", ws.motion.on, m.switchMotion.on, len(sc.rects))
62	}
63}

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