v0.7.1 ff50ee4

history_view_cache_test.go RawHistoryFolder

1package vt
2
3import (
4	"testing"
5
6	"github.com/bnema/vev-vt/core"
7	"github.com/stretchr/testify/require"
8)
9
10func TestHistoryViewReusesUnchangedTail(t *testing.T) {
11	h := NewHistory(HistoryConfig{MaxRows: 8, ChunkRows: 4})
12	require.NoError(t, h.Append([]core.Cell{{Rune: 'a', Style: core.DefaultStyle()}}, LineBound{End: 1}))
13	first := h.View()
14	require.Same(t, first.chunks[0], h.View().chunks[0])
15	require.LessOrEqual(t, testing.AllocsPerRun(20, func() { _ = h.View() }), float64(1))
16	require.Same(t, first.chunks[0], h.SealAndView().chunks[0])
17}
18
19func TestHistoryTailCacheInvalidationPreservesRetainedViews(t *testing.T) {
20	for _, tt := range []struct {
21		name   string
22		mutate func(*History) error
23		want   int
24	}{
25		{"append", func(h *History) error {
26			return h.Append([]core.Cell{{Rune: 'c', Style: core.DefaultStyle()}}, LineBound{End: 1})
27		}, 3},
28		{"byte eviction", func(h *History) error {
29			return h.SetLimits(HistoryConfig{MaxBytes: core.StoredCellLogicalBytes + core.RowDescriptorLogicalBytes + core.StyleRecordLogicalBytes, ChunkRows: 4})
30		}, 1},
31		{"disable", func(h *History) error { return h.SetLimits(HistoryConfig{}) }, 0},
32		{"seal and row eviction", func(h *History) error { return h.SetLimits(HistoryConfig{MaxRows: 1, ChunkRows: 1}) }, 1},
33	} {
34		t.Run(tt.name, func(t *testing.T) {
35			h := NewHistory(HistoryConfig{MaxRows: 8, ChunkRows: 4})
36			for _, r := range "ab" {
37				require.NoError(t, h.Append([]core.Cell{{Rune: r, Style: core.DefaultStyle()}}, LineBound{End: 1}))
38			}
39			before := h.View()
40			snapshot := h.SnapshotView()
41			require.NoError(t, tt.mutate(h))
42			require.Equal(t, tt.want, h.View().Len())
43			require.Equal(t, 2, before.Len())
44			require.Equal(t, 'a', before.Cell(0, 0).Rune)
45			require.Equal(t, 'b', before.Cell(0, 1).Rune)
46			require.Equal(t, 'a', snapshot.Tail().Cell(0, 0).Rune)
47			require.Equal(t, 'b', snapshot.Tail().Cell(0, 1).Rune)
48		})
49	}
50}

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