main f2d166b

action_test.go RawHistoryFolder

1package core_test
2
3import (
4	"slices"
5	"strings"
6	"testing"
7
8	"github.com/bnema/neferwl/internal/core"
9	"github.com/bnema/neferwl/internal/ports"
10)
11
12// altCmdDefaults is the default config with keyboard.cmd = alt. The loader
13// drops binds that use both cmd and alt then; so does this helper.
14func altCmdDefaults() ports.Config {
15	cfg := scrollDefaults()
16	cfg.Keyboard.CmdKey = "alt"
17	for combo := range cfg.Binds {
18		parts := strings.Split(combo, "+")
19		mods := parts[:len(parts)-1]
20		if slices.Contains(mods, "Alt") && slices.Contains(mods, "Cmd") {
21			delete(cfg.Binds, combo)
22		}
23	}
24	return cfg
25}
26
27func TestDefaultBindsAccepted(t *testing.T) {
28	for _, cmd := range []string{"super", "alt"} {
29		cfg := scrollDefaults()
30		if cmd == "alt" {
31			cfg = altCmdDefaults()
32		}
33		if _, err := core.New(cfg, core.Channels{Scenes: make(chan []ports.Scene, 1)}, core.Options{}); err != nil {
34			t.Fatalf("cmd=%s: %v", cmd, err)
35		}
36	}
37}
38
39func TestResizeArg(t *testing.T) {
40	for _, tc := range []struct {
41		a          core.Action
42		axis, step int
43		ok         bool
44	}{
45		{"set-column-width +1", core.ResizeWidth, 1, true},
46		{"set-column-width -5", core.ResizeWidth, -5, true},
47		{"set-column-width +16", core.ResizeWidth, 16, true},
48		{"set-window-height +100%", core.ResizeHeight, 100, true},
49		{"set-window-height -1%", core.ResizeHeight, -1, true},
50		{"set-column-width 1", 0, 0, false},
51		{"set-column-width +0", 0, 0, false},
52		{"set-column-width +17", 0, 0, false},
53		{"set-column-width +10%", 0, 0, false},
54		{"set-column-width +-1", 0, 0, false},
55		{"set-column-width ++1", 0, 0, false},
56		{"set-window-height +10", 0, 0, false},
57		{"set-window-height +101%", 0, 0, false},
58		{"set-window-height +0%", 0, 0, false},
59		{"set-window-height", 0, 0, false},
60		{"cycle-column-width", 0, 0, false},
61	} {
62		axis, step, ok := core.ResizeArg(tc.a)
63		if axis != tc.axis || step != tc.step || ok != tc.ok {
64			t.Errorf("%q: %d %d %v", tc.a, axis, step, ok)
65		}
66	}
67}

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