paste_batch_test.go RawHistoryFolder

1package client
2
3import (
4	"testing"
5
6	"github.com/stretchr/testify/require"
7)
8
9func TestPasteCoalescerBatchBoundaryPreservesOrdinaryBytes(t *testing.T) {
10	for _, input := range []string{"", "hello", "\x1b", "word\x1b[20"} {
11		t.Run(input, func(t *testing.T) {
12			coalescer, _, collector := newTestCoalescer()
13			t.Cleanup(coalescer.Close)
14			require.True(t, coalescer.Idle())
15			coalescer.Scan([]byte(input))
16			require.True(t, coalescer.EndBatch())
17			require.True(t, coalescer.Idle())
18			var got string
19			for _, emitted := range collector.snapshot() {
20				got += string(emitted)
21			}
22			require.Equal(t, input, got)
23			before := collector.snapshot()
24			require.True(t, coalescer.EndBatch())
25			require.Equal(t, before, collector.snapshot(), "batch end cannot duplicate an already emitted prefix")
26			coalescer.Scan([]byte("next"))
27			require.Equal(t, []byte("next"), collector.snapshot()[len(before)], "batch end must not close the input owner")
28		})
29	}
30}
31
32func TestPasteCoalescerBatchBoundaryDoesNotTerminateHumanPaste(t *testing.T) {
33	coalescer, _, collector := newTestCoalescer()
34	t.Cleanup(coalescer.Close)
35	coalescer.Scan([]byte("\x1b[200~human"))
36	require.False(t, coalescer.Idle())
37	require.False(t, coalescer.EndBatch(), "automation cannot end somebody else's open paste")
38	require.Empty(t, collector.snapshot())
39	require.True(t, coalescer.Buffering())
40	coalescer.Scan([]byte("\x1b[201~"))
41	require.True(t, coalescer.Idle())
42	require.Equal(t, [][]byte{[]byte("\x1b[200~human\x1b[201~")}, collector.snapshot())
43	coalescer.Close()
44	require.False(t, coalescer.Idle())
45	require.False(t, coalescer.EndBatch())
46}
47
48// Idle reports that the coalescer holds no paste or undecided prefix bytes.
49func (c *pasteCoalescer) Idle() bool {
50	c.mu.Lock()
51	defer c.mu.Unlock()
52	return !c.closed && !c.buffering && len(c.pending) == 0 && len(c.buf) == 0
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