detached 2b4d718

test(input): add missing test coverage for routing and key classification

Add TestKeyboardHandler_SetRouteKey, quotedbl/caret cases for
IsTextInputKey, and shift+E case for RoutePassToWidget.
commit
2b4d718c84b88cd87024a21c016c8694ff6c89c7
author
bnema · · 2026-03-10 22:09 UTC
committer
brice · · 2026-03-11 04:05 UTC
parent
d91ea3e
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
1 file · +26 -0
M internal/ui/input/keyboard_test.go +26 -0
@@ -48,6 +48,8 @@ func TestIsTextInputKey(t *testing.T) {
4848 {"apostrophe", 0x027, true},
4949 {"grave accent", 0x060, true},
5050 {"tilde", 0x07e, true},
51+ {"quotedbl", 0x022, true},
52+ {"caret", 0x05e, true},
5153
5254 // Dead keys (used by US International layout)
5355 {"dead acute", 0xfe51, true},
@@ -99,6 +101,7 @@ func TestHandleKeyPress_RoutePassToWidget(t *testing.T) {
99101 }{
100102 {"plain 'e'", uint('e'), 0},
101103 {"plain 'a'", uint('a'), 0},
104+ {"shift 'E'", uint('E'), gdk.ShiftMaskValue},
102105 {"space", 0x020, 0},
103106 {"digit 1", uint('1'), 0},
104107 }
@@ -179,6 +182,29 @@ func TestHandleKeyPress_ModalModeIgnoresRoute(t *testing.T) {
179182 assert.True(t, result, "modal mode should consume unknown keys regardless of route")
180183 }
181184
185+func TestKeyboardHandler_SetRouteKey(t *testing.T) {
186+ ctx := context.Background()
187+ cfg := &config.Config{}
188+ h := NewKeyboardHandler(ctx, cfg)
189+
190+ // Default: no callback set
191+ h.mu.RLock()
192+ fn := h.routeKey
193+ h.mu.RUnlock()
194+ assert.Nil(t, fn, "routeKey should be nil by default")
195+
196+ // Set callback
197+ h.SetRouteKey(func(kc KeyContext) KeyRoute {
198+ return RoutePassToWidget
199+ })
200+
201+ h.mu.RLock()
202+ fn = h.routeKey
203+ h.mu.RUnlock()
204+ assert.NotNil(t, fn, "routeKey should be set")
205+ assert.Equal(t, RoutePassToWidget, fn(KeyContext{}))
206+}
207+
182208 func TestHandleKeyPress_NoRouteCallback_DefaultsToShortcuts(t *testing.T) {
183209 ctx := context.Background()
184210 cfg := &config.Config{}
@@ -48,6 +48,8 @@ func TestIsTextInputKey(t *testing.T) {
48 {"apostrophe", 0x027, true},48 {"apostrophe", 0x027, true},
49 {"grave accent", 0x060, true},49 {"grave accent", 0x060, true},
50 {"tilde", 0x07e, true},50 {"tilde", 0x07e, true},
51+ {"quotedbl", 0x022, true},
52+ {"caret", 0x05e, true},
51 53
52 // Dead keys (used by US International layout)54 // Dead keys (used by US International layout)
53 {"dead acute", 0xfe51, true},55 {"dead acute", 0xfe51, true},
@@ -99,6 +101,7 @@ func TestHandleKeyPress_RoutePassToWidget(t *testing.T) {
99 }{101 }{
100 {"plain 'e'", uint('e'), 0},102 {"plain 'e'", uint('e'), 0},
101 {"plain 'a'", uint('a'), 0},103 {"plain 'a'", uint('a'), 0},
104+ {"shift 'E'", uint('E'), gdk.ShiftMaskValue},
102 {"space", 0x020, 0},105 {"space", 0x020, 0},
103 {"digit 1", uint('1'), 0},106 {"digit 1", uint('1'), 0},
104 }107 }
@@ -179,6 +182,29 @@ func TestHandleKeyPress_ModalModeIgnoresRoute(t *testing.T) {
179 assert.True(t, result, "modal mode should consume unknown keys regardless of route")182 assert.True(t, result, "modal mode should consume unknown keys regardless of route")
180 }183 }
181 184
185+func TestKeyboardHandler_SetRouteKey(t *testing.T) {
186+ ctx := context.Background()
187+ cfg := &config.Config{}
188+ h := NewKeyboardHandler(ctx, cfg)
189+
190+ // Default: no callback set
191+ h.mu.RLock()
192+ fn := h.routeKey
193+ h.mu.RUnlock()
194+ assert.Nil(t, fn, "routeKey should be nil by default")
195+
196+ // Set callback
197+ h.SetRouteKey(func(kc KeyContext) KeyRoute {
198+ return RoutePassToWidget
199+ })
200+
201+ h.mu.RLock()
202+ fn = h.routeKey
203+ h.mu.RUnlock()
204+ assert.NotNil(t, fn, "routeKey should be set")
205+ assert.Equal(t, RoutePassToWidget, fn(KeyContext{}))
206+}
207+
182 func TestHandleKeyPress_NoRouteCallback_DefaultsToShortcuts(t *testing.T) {208 func TestHandleKeyPress_NoRouteCallback_DefaultsToShortcuts(t *testing.T) {
183 ctx := context.Background()209 ctx := context.Background()
184 cfg := &config.Config{}210 cfg := &config.Config{}

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 8

Tags 42

↑↓ moveenter openesc close