v0.3.0 cf370a0

action_test.go RawHistoryFolder

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

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