main f2d166b

screen_geometry_test.go RawHistoryFolder

1package core
2
3import (
4	"testing"
5
6	"github.com/stretchr/testify/assert"
7)
8
9func geometryTiles() []tile {
10	return []tile{{"A", 0, 0, 200, 100}, {"B", 200, 0, 400, 200}}
11}
12
13func TestScreenAt(t *testing.T) {
14	c := layoutCore(0, geometryTiles()...)
15	for _, tc := range []struct {
16		x, y float64
17		want int
18	}{
19		{199, 50, 0}, {200, 50, 1}, {250, 150, 1}, {100, 150, -1}, {-1, 0, -1},
20	} {
21		assert.Equal(t, tc.want, c.screenAt(tc.x, tc.y), "(%v,%v)", tc.x, tc.y)
22	}
23
24	p := layoutCore(0, tile{"", 0, 0, 200, 100})
25	assert.Equal(t, -1, p.screenAt(10, 10), "a placeholder is never returned")
26}
27
28func TestClampPointer(t *testing.T) {
29	c := layoutCore(0, geometryTiles()...)
30	x, y := c.clampPointer(0, 0, 100, 50)
31	assert.Equal(t, [2]float64{100, 50}, [2]float64{x, y})
32	x, y = c.clampPointer(100, 50, 100, 150)
33	assert.Equal(t, [2]float64{100, 99}, [2]float64{x, y})
34	x, y = c.clampPointer(-5, -5, -10, -10)
35	assert.Equal(t, [2]float64{0, 0}, [2]float64{x, y})
36
37	none := layoutCore(0, tile{"", 0, 0, 200, 100})
38	x, y = none.clampPointer(0, 0, 500, 500)
39	assert.Equal(t, [2]float64{500, 500}, [2]float64{x, y})
40}
41
42func TestScreenAtAllocations(t *testing.T) {
43	c := layoutCore(0, geometryTiles()...)
44	n := testing.AllocsPerRun(100, func() {
45		c.screenAt(250, 150)
46		c.clampPointer(100, 50, 100, 150)
47	})
48	assert.Zero(t, n)
49}

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