v0.3.16 fb1bc82

slash_suggest_test.go RawHistoryFolder

1package modes
2
3import "testing"
4
5func TestSlashSuggesterHidesUnjailUntilJailed(t *testing.T) {
6	s := newSlashSuggester()
7
8	if got := commandNames(s.matches("/unj")); contains(got, "/unjail") {
9		t.Fatalf("/unjail should be hidden while not jailed, got %v", got)
10	}
11	if got := commandNames(s.matches("/ja")); !contains(got, "/jail") {
12		t.Fatalf("/jail should be visible while not jailed, got %v", got)
13	}
14
15	s.SetJailed(true)
16	if got := commandNames(s.matches("/unj")); !contains(got, "/unjail") {
17		t.Fatalf("/unjail should be visible while jailed, got %v", got)
18	}
19	if got := commandNames(s.matches("/ja")); contains(got, "/jail") {
20		t.Fatalf("/jail should be hidden while jailed, got %v", got)
21	}
22}
23
24func TestSlashSuggesterShowsLlamaOnlyWhenConfigured(t *testing.T) {
25	s := newSlashSuggester()
26	if got := commandNames(s.matches("/llama")); contains(got, "/llama") {
27		t.Fatalf("/llama visible without login: %v", got)
28	}
29	s.SetLlamaConfigured(true)
30	if got := commandNames(s.matches("/llama")); !contains(got, "/llama") {
31		t.Fatalf("/llama missing with login: %v", got)
32	}
33}
34
35func TestSlashSuggesterHasSwarm(t *testing.T) {
36	s := newSlashSuggester()
37	if got := commandNames(s.matches("/sw")); !contains(got, "/swarm") {
38		t.Fatalf("/swarm missing from suggestions, got %v", got)
39	}
40}
41
42func TestSlashCommandsAreCaseInsensitive(t *testing.T) {
43	s := newSlashSuggester()
44	if got := commandNames(s.matches("/EX")); !contains(got, "/exit") {
45		t.Fatalf("/EX did not suggest /exit: %v", got)
46	}
47	if !isKnownSlashCommand("/Exit") {
48		t.Fatal("/Exit was not recognized as a built-in command")
49	}
50	if !slashCancelsTurn("/CLEAR") {
51		t.Fatal("/CLEAR did not retain /clear cancellation semantics")
52	}
53}
54
55func TestSlashSuggesterBuiltinsShadowExtensionsCaseInsensitively(t *testing.T) {
56	s := newSlashSuggester()
57	s.SetExtra([]slashCommand{{Name: "/EXIT", Desc: "extension exit"}})
58	matches := commandNames(s.matches("/exit"))
59	if len(matches) != 1 || matches[0] != "/exit" {
60		t.Fatalf("matches = %v, want only built-in /exit", matches)
61	}
62}
63
64func commandNames(cmds []slashCommand) []string {
65	out := make([]string, 0, len(cmds))
66	for _, c := range cmds {
67		if !c.Header {
68			out = append(out, c.Name)
69		}
70	}
71	return out
72}
73
74func contains(xs []string, want string) bool {
75	for _, x := range xs {
76		if x == want {
77			return true
78		}
79	}
80	return false
81}

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 1

Tags 477

↑↓ moveenter openesc close