v0.5.0 31affde

frame_bounds_test.go RawHistoryFolder

1package core
2
3import (
4	"math"
5	"testing"
6
7	"github.com/stretchr/testify/require"
8)
9
10func TestFrameColumnsCannotAddressAdjacentRows(t *testing.T) {
11	for _, x := range []int{-1, 3, 4, math.MaxInt} {
12		f := NewFrame(3, 3)
13		f.Set(0, 1, Cell{Rune: 'x', Style: DefaultStyle()})
14		f.ScrollUp(0, 2, 1)
15		before := f.Clone()
16		for y := range f.Height {
17			require.Panics(t, func() { f.Cell(x, y) })
18			require.Panics(t, func() { f.Set(x, y, Cell{Rune: 'z'}) })
19		}
20		for y := range f.Height {
21			require.Equal(t, before.Row(y), f.Row(y))
22		}
23		require.NoError(t, f.CheckInvariants())
24	}
25}
26
27func TestFrameRejectsInvalidRows(t *testing.T) {
28	for _, width := range []int{0, 3} {
29		f := NewFrame(width, 3)
30		require.Len(t, f.Row(1), width)
31		for _, y := range []int{-1, 3, math.MaxInt} {
32			require.Panics(t, func() { f.Row(y) })
33			require.Panics(t, func() { f.Cell(0, y) })
34			require.Panics(t, func() { f.Set(0, y, BlankCell()) })
35		}
36		require.NoError(t, f.CheckInvariants())
37	}
38}
39
40func TestFillRowClipsColumns(t *testing.T) {
41	f := NewFrame(3, 3)
42	f.ScrollDown(0, 2, 1)
43	f.FillRow(1, math.MinInt, math.MaxInt, Cell{Rune: 'x', Style: DefaultStyle()})
44	for y := range f.Height {
45		for x := range f.Width {
46			want := rune(' ')
47			if y == 1 {
48				want = 'x'
49			}
50			require.Equal(t, want, f.Cell(x, y).Rune)
51		}
52	}
53	require.NoError(t, f.CheckInvariants())
54}
55
56func TestReplaceInvalidSourcePreservesDestination(t *testing.T) {
57	for _, src := range []Frame{{}, {Width: 2, Height: 2}, NewFrame(0, 2), NewFrame(2, 0)} {
58		dst := NewFrame(2, 2)
59		dst.Set(1, 1, Cell{Rune: 'x', Style: DefaultStyle()})
60		before := dst.Clone()
61		dst.Replace(src)
62		require.Equal(t, before.Width, dst.Width)
63		require.Equal(t, before.Height, dst.Height)
64		for y := range dst.Height {
65			require.Equal(t, before.Row(y), dst.Row(y))
66		}
67		require.NoError(t, dst.CheckInvariants())
68	}
69}

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