hint_internal_test.go RawHistoryFolder

1package core
2
3import (
4	"github.com/bnema/neferwl/internal/ports"
5	"github.com/stretchr/testify/require"
6	"math"
7	"testing"
8)
9
10func TestHintLabelGeometry(t *testing.T) {
11	for _, scale := range []float64{1, 1.5} {
12		sc := &screen{scale: scale, info: ports.OutputInfo{Width: 1500, Height: 1200}}
13		sc.mon = newMonitor("", "")
14		sc.mon.SetOutput(int(float64(sc.info.Width)/sc.scale), int(float64(sc.info.Height)/sc.scale))
15		c := &Core{}
16		c.cfg.Hint.Size = 200
17		w, h := c.hintLabelSize(sc)
18		font := math.Min(200, 256/scale)
19		require.Equal(t, int(math.Ceil(1.2*font+6*font/13+2/scale+1)), w)
20		require.Equal(t, int(math.Ceil(1.25*font+2*font/13+2/scale+1)), h)
21		bounds := sc.rect()
22		// Corner separation exceeds label width, but right-edge clamping folds
23		// the second label back over the first.
24		a := hintTarget{rect: ports.Rect{X: bounds.W - w - 1, Y: bounds.H - h - 1}, score: 1}
25		b := hintTarget{rect: ports.Rect{X: bounds.W - 1, Y: bounds.H - 1}, score: .5}
26		require.Len(t, c.hintSpread(sc, []hintTarget{a, b}), 1)
27		b.rect = ports.Rect{X: 0, Y: 0}
28		require.Len(t, c.hintSpread(sc, []hintTarget{a, b}), 2)
29	}
30}
31
32func TestHintSpreadBudget(t *testing.T) {
33	sc := &screen{scale: 1, info: ports.OutputInfo{Width: 1000000, Height: 1000}}
34	sc.mon = newMonitor("", "")
35	sc.mon.SetOutput(int(float64(sc.info.Width)/sc.scale), int(float64(sc.info.Height)/sc.scale))
36	c := &Core{}
37	ts := make([]hintTarget, 4*hintMaxTargets+10)
38	for i := range ts {
39		ts[i] = hintTarget{rect: ports.Rect{X: 100 + i*100, Y: 100}, score: float32(i)}
40	}
41	got := c.hintSpread(sc, ts)
42	require.Len(t, got, 4*hintMaxTargets)
43	require.Equal(t, float32(len(ts)-1), got[0].score)
44	require.Equal(t, float32(10), got[len(got)-1].score)
45}

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 25

Tags 10

↑↓ moveenter openesc close