v0.27.0 01c3d31

sse.go RawHistoryFolder

1package provider
2
3import (
4	"bufio"
5	"io"
6	"strings"
7)
8
9// sseEvent is one parsed event from a text/event-stream.
10type sseEvent struct {
11	Event string // value of "event:" field (may be empty)
12	Data  string // concatenated "data:" lines
13	Err   error  // terminal scanner failure, if any
14}
15
16// readSSE reads events from r and sends them on out. A scanner failure is
17// delivered as a final event before out closes.
18func readSSE(r io.Reader, out chan<- sseEvent) {
19	defer close(out)
20	sc := bufio.NewScanner(r)
21	sc.Buffer(make([]byte, 0, 64*1024), 10*1024*1024)
22
23	var ev sseEvent
24	flush := func() {
25		if ev.Data == "" && ev.Event == "" {
26			return
27		}
28		out <- ev
29		ev = sseEvent{}
30	}
31
32	for sc.Scan() {
33		line := sc.Text()
34		if line == "" {
35			flush()
36			continue
37		}
38		if strings.HasPrefix(line, ":") {
39			// comment / keep-alive
40			continue
41		}
42		field, value, ok := strings.Cut(line, ":")
43		if !ok {
44			field = line
45			value = ""
46		}
47		// optional single leading space after ':'
48		value = strings.TrimPrefix(value, " ")
49		switch field {
50		case "event":
51			ev.Event = value
52		case "data":
53			if ev.Data != "" {
54				ev.Data += "\n"
55			}
56			ev.Data += value
57		}
58	}
59	flush()
60	if err := sc.Err(); err != nil {
61		out <- sseEvent{Err: err}
62	}
63}

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 1

Tags 476

↑↓ moveenter openesc close