v0.4.0 0b9cfda

frame_test.go RawHistoryFolder

1package core
2
3import "testing"
4
5func TestFrameCanonicalOffsetsAndInvariants(t *testing.T) {
6	f := NewFrame(4, 3)
7	for y := range f.Height {
8		if f.lineOffset[y] != y*f.Width {
9			t.Fatalf("lineOffset[%d] = %d, want %d", y, f.lineOffset[y], y*f.Width)
10		}
11	}
12	if err := f.CheckInvariants(); err != nil {
13		t.Fatalf("fresh frame invariants: %v", err)
14	}
15}
16
17func TestCheckInvariantsDetectsBrokenRotation(t *testing.T) {
18	f := NewFrame(4, 3)
19	f.lineOffset[1] = f.lineOffset[0]
20	if err := f.CheckInvariants(); err == nil {
21		t.Fatal("expected duplicate physical row to be rejected")
22	}
23
24	f = NewFrame(4, 3)
25	f.lineOffset[0] = 1
26	if err := f.CheckInvariants(); err == nil {
27		t.Fatal("expected non-multiple offset to be rejected")
28	}
29
30	f = NewFrame(4, 3)
31	f.lineOffset[2] = 99
32	if err := f.CheckInvariants(); err == nil {
33		t.Fatal("expected out-of-range offset to be rejected")
34	}
35}
36
37func TestReplacePreservesLogicalRows(t *testing.T) {
38	dst := NewFrame(3, 3)
39	dst.Set(0, 0, Cell{Rune: 'x'})
40	dst.ScrollUp(0, 2, 1)
41
42	src := NewFrame(3, 3)
43	for y, row := range []string{"abc", "def", "ghi"} {
44		for x, r := range row {
45			src.Set(x, y, Cell{Rune: r})
46		}
47	}
48	src.ScrollUp(0, 2, 1)
49
50	dst.Replace(src)
51	for y, want := range []string{"def", "ghi", "   "} {
52		for x, r := range want {
53			if got := dst.At(x, y).Rune; got != r {
54				t.Fatalf("row %d col %d = %q, want %q", y, x, got, r)
55			}
56		}
57	}
58	if err := dst.CheckInvariants(); err != nil {
59		t.Fatalf("replaced frame invariants: %v", err)
60	}
61}

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 2

Tags 13

↑↓ moveenter openesc close