ui_clock_test.go RawHistoryFolder

1package client
2
3import (
4	"sync"
5	"testing"
6	"time"
7
8	"github.com/bnema/vev/internal/ports"
9	"github.com/bnema/vev/internal/protocol"
10)
11
12type attachPaletteClock struct {
13	timers          chan *attachPaletteTimer
14	handshakeTimers chan *attachPaletteTimer
15}
16
17type attachPaletteTimer struct {
18	ch       chan time.Time
19	stopped  chan struct{}
20	stopOnce sync.Once
21	duration time.Duration
22}
23
24func newAttachPaletteClock() *attachPaletteClock {
25	return &attachPaletteClock{
26		timers:          make(chan *attachPaletteTimer, 16),
27		handshakeTimers: make(chan *attachPaletteTimer, 1),
28	}
29}
30
31func (*attachPaletteClock) Now() time.Time { return time.Time{} }
32func (c *attachPaletteClock) NewTimer(delay time.Duration) ports.Timer {
33	timer := &attachPaletteTimer{ch: make(chan time.Time, 1), stopped: make(chan struct{}), duration: delay}
34	if delay == protocol.HandshakeTimeout {
35		select {
36		case c.handshakeTimers <- timer:
37		default:
38			panic("unexpected extra handshake timer")
39		}
40	} else {
41		c.timers <- timer
42	}
43	return timer
44}
45func (t *attachPaletteTimer) C() <-chan time.Time    { return t.ch }
46func (*attachPaletteTimer) Reset(time.Duration) bool { return false }
47func (t *attachPaletteTimer) Stop() bool {
48	t.stopOnce.Do(func() { close(t.stopped) })
49	return true
50}
51func (t *attachPaletteTimer) fire() { t.ch <- time.Time{} }
52
53func requireTimer(t *testing.T, timers <-chan *attachPaletteTimer, message string) *attachPaletteTimer {
54	t.Helper()
55	select {
56	case timer := <-timers:
57		return timer
58	case <-time.After(time.Second):
59		t.Fatal(message)
60		return nil
61	}
62}
63
64func requireSignal(t *testing.T, signal <-chan struct{}, message string) {
65	t.Helper()
66	select {
67	case <-signal:
68	case <-time.After(time.Second):
69		t.Fatal(message)
70	}
71}

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