main ece7682

status_test.go RawHistoryFolder

1package copy
2
3import (
4	"testing"
5
6	renderer "github.com/bnema/vev-vt/ansi"
7	"github.com/stretchr/testify/require"
8)
9
10func TestDrawCopyStatus(t *testing.T) {
11	tests := []struct {
12		name  string
13		width int
14		lines []string
15		query string
16		want  string
17	}{
18		{name: "empty document", width: 12, want: " [SCROLL] 0/"},
19		{name: "position", width: 16, lines: []string{"a", "b"}, want: " [SCROLL] 2/2   "},
20		{name: "truncated", width: 5, lines: []string{"a"}, want: " [SCR"},
21		{name: "zero width", width: 0, lines: []string{"a"}, want: ""},
22		{name: "multibyte query is contiguous", width: 22, lines: []string{"éa"}, query: "é", want: " [SCROLL] 1/1 1/1 /é "},
23	}
24	for _, tt := range tests {
25		t.Run(tt.name, func(t *testing.T) {
26			m := modeFor(tt.lines, 1)
27			if tt.query != "" {
28				m.Search(tt.query)
29			}
30			row := make([]renderer.Cell, tt.width)
31			drawCopyStatus(row, m, m.document.Len(), renderer.Style{})
32			var got []rune
33			for _, cell := range row {
34				got = append(got, cell.Rune)
35			}
36			require.Equal(t, tt.want, string(got)[:len(tt.want)])
37			require.Len(t, row, tt.width)
38		})
39	}
40}
41
42// TestRenderRowsRangeReusesRowsAcrossWidths guards the pooled row buffer:
43// a narrow render between two wide ones must not leak cells.
44func TestRenderRowsRangeReusesRowsAcrossWidths(t *testing.T) {
45	wide := NewMode(NewDocument(NewSnapshotFromRows([][]renderer.Cell{row("abcdefgh")}, 8, 1), ""))
46	narrow := NewMode(NewDocument(NewSnapshotFromRows([][]renderer.Cell{row("xy")}, 2, 1), ""))
47	for _, m := range []*Mode{wide, narrow, wide} {
48		full := m.Render()
49		m.RenderRowsRange(0, 1, func(y int, got []renderer.Cell) {
50			require.Equal(t, full.Row(y), got)
51		})
52	}
53}

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 12

Tags 11

↑↓ moveenter openesc close