feat/hints a471fa4

overview_stash_input_test.go RawHistoryFolder

1package core
2
3import (
4	"slices"
5	"testing"
6	"time"
7
8	"github.com/bnema/neferwl/internal/ports"
9)
10
11func TestOverviewStashInputNavigation(t *testing.T) {
12	for _, input := range []string{"swipe", "wheel", "bind"} {
13		t.Run(input, func(t *testing.T) {
14			c, _, sc, _ := stashRig(t, true)
15			m := sc.mon
16			w := m.Current()
17			before := stashIDs(w)
18			m.ToggleOverview()
19			var at time.Duration
20			send := func(ev ports.InputEvent) {
21				t.Helper()
22				if err := c.handleInput(t.Context(), ev); err != nil {
23					t.Fatal(err)
24				}
25			}
26			move := func(dx, dy int) {
27				t.Helper()
28				switch input {
29				case "swipe":
30					at += time.Second
31					send(ports.SwipeBegin{Fingers: 3, Time: at})
32					for range 3 {
33						at += 8 * time.Millisecond
34						send(ports.SwipeUpdate{DX: float64(dx) * 40, DY: float64(dy) * 40, Time: at})
35					}
36					send(ports.SwipeEnd{Time: at})
37				case "wheel":
38					m.overviewScroll(ports.PointerAxis{Source: ports.AxisWheel,
39						Horizontal: ports.ScrollAxis{Set: dx != 0, Value: float64(dx) * 70, V120: int32(dx * 120)},
40						Vertical:   ports.ScrollAxis{Set: dy != 0, Value: float64(dy) * 70, V120: int32(dy * 120)}})
41					c.scrollStop(ports.PointerAxis{Vertical: ports.ScrollAxis{Stop: true}})
42				case "bind":
43					var a Action
44					switch {
45					case dx == 0 && dy < 0:
46						a = ActionFocusWindowUp
47					case dx == 0 && dy > 0:
48						a = ActionFocusWindowDown
49					case dx > 0 && dy == 0:
50						a = ActionFocusColumnRight
51					case dx < 0 && dy == 0:
52						a = ActionFocusColumnLeft
53					default:
54						t.Fatalf("no bind for move %d,%d", dx, dy)
55					}
56					m.overviewFocus(a)
57				}
58			}
59			move(0, -1)
60			if m.cardAt(w) != 1 {
61				t.Fatalf("up selected card %d, want 1", m.cardAt(w))
62			}
63			move(0, 1)
64			move(0, 1)
65			if m.Current() != w || m.cardAt(w) != 0 || !slices.Equal(stashIDs(w), before) {
66				t.Fatalf("down past the last card: card %d, want it to wrap round to 0 in order", m.cardAt(w))
67			}
68			move(1, 0)
69			if m.cardAt(w) >= 0 {
70				t.Fatal("right did not leave the stash")
71			}
72		})
73	}
74}
75
76// In a vertical overview, a focus-workspace bind over the unfolded stash
77// changes workspace, in its direction, wrapping round or not: the move
78// keys walk the cards.
79func TestOverviewWorkspaceBindLeavesCarousel(t *testing.T) {
80	for _, n := range []int{2, 3} {
81		m := overviewMonitor()
82		w := m.Current()
83		for id := WindowID(5); id < WindowID(5+n); id++ {
84			w.AddWindow(id)
85			w.FocusID(id)
86			w.ToggleWindowStash()
87		}
88		w.FocusID(1)
89		m.Focus(1)
90		m.AddWindow(30)
91		m.Focus(0)
92		m.ToggleOverview()
93		m.OverviewMove(-1, 0)
94		if m.overviewAxis() != verticalAxis || m.cardAt(w) < 0 {
95			t.Fatalf("%d cards, setup: no card selected in a vertical overview", n)
96		}
97		m.overviewFocus(ActionFocusWorkspaceNext)
98		if m.Current() != m.Workspaces[1] || m.cardAt(w) >= 0 {
99			t.Fatalf("%d cards: focus-workspace-next went to workspace %d, card %d", n, indexOf(m.Workspaces, m.Current()), m.cardAt(w))
100		}
101	}
102}

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