v0.33.1 9577fee

editable_focus_test.go RawHistoryFolder

1package content
2
3import (
4	"context"
5	"testing"
6
7	"github.com/stretchr/testify/assert"
8	"github.com/stretchr/testify/mock"
9	"github.com/stretchr/testify/require"
10
11	"github.com/bnema/dumber/internal/application/port"
12	"github.com/bnema/dumber/internal/application/port/mocks"
13	"github.com/bnema/dumber/internal/domain/entity"
14)
15
16func TestEditableFocusCallback_ForwardsPaneID(t *testing.T) {
17	c := newMinimalCoordinator()
18	wv := mocks.NewMockWebView(t)
19
20	var callbacks *port.WebViewCallbacks
21	wv.EXPECT().ID().Return(port.WebViewID(1)).Once()
22	wv.EXPECT().Generation().Return(uint64(0)).Twice()
23	wv.EXPECT().SetCallbacks(mock.Anything).Run(func(cb *port.WebViewCallbacks) {
24		callbacks = cb
25	}).Once()
26
27	var gotPaneID entity.PaneID
28	var gotEditable bool
29	c.SetOnEditableFocusChanged(func(paneID entity.PaneID, editable bool) {
30		gotPaneID = paneID
31		gotEditable = editable
32	})
33
34	c.setupWebViewCallbacks(context.Background(), entity.PaneID("pane-1"), wv)
35	require.NotNil(t, callbacks)
36	require.NotNil(t, callbacks.OnEditableFocusChanged)
37
38	callbacks.OnEditableFocusChanged(true)
39
40	assert.Equal(t, entity.PaneID("pane-1"), gotPaneID)
41	assert.True(t, gotEditable)
42}
43
44func TestEditableFocusCallback_BackgroundPaneDoesNotConfusePaneOwnership(t *testing.T) {
45	c := newMinimalCoordinator()
46	c.SetActivePaneOverride(entity.PaneID("pane-a"))
47
48	wvA := mocks.NewMockWebView(t)
49	wvB := mocks.NewMockWebView(t)
50
51	var callbacksA *port.WebViewCallbacks
52	var callbacksB *port.WebViewCallbacks
53	wvA.EXPECT().ID().Return(port.WebViewID(1)).Once()
54	wvA.EXPECT().Generation().Return(uint64(0)).Twice()
55	wvA.EXPECT().SetCallbacks(mock.Anything).Run(func(cb *port.WebViewCallbacks) {
56		callbacksA = cb
57	}).Once()
58	wvB.EXPECT().ID().Return(port.WebViewID(2)).Once()
59	wvB.EXPECT().Generation().Return(uint64(0)).Twice()
60	wvB.EXPECT().SetCallbacks(mock.Anything).Run(func(cb *port.WebViewCallbacks) {
61		callbacksB = cb
62	}).Once()
63
64	type event struct {
65		paneID   entity.PaneID
66		editable bool
67	}
68	var events []event
69	c.SetOnEditableFocusChanged(func(paneID entity.PaneID, editable bool) {
70		events = append(events, event{paneID: paneID, editable: editable})
71	})
72
73	c.setupWebViewCallbacks(context.Background(), entity.PaneID("pane-a"), wvA)
74	c.setupWebViewCallbacks(context.Background(), entity.PaneID("pane-b"), wvB)
75	require.NotNil(t, callbacksA)
76	require.NotNil(t, callbacksB)
77
78	callbacksB.OnEditableFocusChanged(true)
79	callbacksA.OnEditableFocusChanged(false)
80
81	require.Len(t, events, 2)
82	assert.Equal(t, event{paneID: entity.PaneID("pane-b"), editable: true}, events[0])
83	assert.Equal(t, event{paneID: entity.PaneID("pane-a"), editable: false}, events[1])
84}

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