v0.7.1 ff50ee4

limits.go RawHistoryFolder

1package html
2
3import (
4	"errors"
5)
6
7const (
8	defaultMaxCells          = 1_000_000
9	defaultMaxRowsPerUpdate  = 10_000
10	defaultMaxGeneratedBytes = 64 << 20
11	defaultMaxStyles         = 65_536
12)
13
14var (
15	// ErrPendingDraw reports an attempt to prepare while a draw is pending.
16	ErrPendingDraw = errors.New("html: prepared draw already pending")
17	// ErrFinalizedDraw reports a repeated commit or abort.
18	ErrFinalizedDraw = errors.New("html: prepared draw already finalized")
19	// ErrStaleDraw reports a nil draw or one invalidated by Reset.
20	ErrStaleDraw = errors.New("html: prepared draw is stale")
21	// ErrLimitExceeded reports a configured renderer bound violation.
22	ErrLimitExceeded = errors.New("html: resource limit exceeded")
23	// ErrInvalidLimits reports a negative limit field.
24	ErrInvalidLimits = errors.New("html: limits must not be negative")
25)
26
27// Limits bounds renderer work and retained update data. Zero values select
28// documented safe defaults.
29type Limits struct {
30	MaxCells          int
31	MaxRowsPerUpdate  int
32	MaxGeneratedBytes int
33	MaxStyles         int
34}
35
36// DefaultLimits returns the bounds used for zero-valued limit fields.
37func DefaultLimits() Limits {
38	return Limits{
39		MaxCells:          defaultMaxCells,
40		MaxRowsPerUpdate:  defaultMaxRowsPerUpdate,
41		MaxGeneratedBytes: defaultMaxGeneratedBytes,
42		MaxStyles:         defaultMaxStyles,
43	}
44}
45
46// Options configures a Renderer for its lifetime.
47type Options struct {
48	Limits Limits
49}
50
51func normalizeLimits(limits Limits) (Limits, error) {
52	if limits.MaxCells < 0 || limits.MaxRowsPerUpdate < 0 || limits.MaxGeneratedBytes < 0 || limits.MaxStyles < 0 {
53		return Limits{}, ErrInvalidLimits
54	}
55	defaults := DefaultLimits()
56	if limits.MaxCells == 0 {
57		limits.MaxCells = defaults.MaxCells
58	}
59	if limits.MaxRowsPerUpdate == 0 {
60		limits.MaxRowsPerUpdate = defaults.MaxRowsPerUpdate
61	}
62	if limits.MaxGeneratedBytes == 0 {
63		limits.MaxGeneratedBytes = defaults.MaxGeneratedBytes
64	}
65	if limits.MaxStyles == 0 {
66		limits.MaxStyles = defaults.MaxStyles
67	}
68	return limits, nil
69}

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