v0.2.36 5a4e492

study_test.go RawHistoryFolder

1package modes
2
3import (
4	"os"
5	"path/filepath"
6	"testing"
7)
8
9func TestBuildStudyPrompt(t *testing.T) {
10	tmp := t.TempDir()
11	subdir := filepath.Join(tmp, "internal")
12	if err := os.Mkdir(subdir, 0o755); err != nil {
13		t.Fatal(err)
14	}
15	file := filepath.Join(tmp, "main.go")
16	if err := os.WriteFile(file, []byte("package main\n"), 0o644); err != nil {
17		t.Fatal(err)
18	}
19
20	cases := []struct {
21		name string
22		arg  string
23		cwd  string
24		want string
25	}{
26		{
27			name: "empty arg keeps the original cwd prompt",
28			arg:  "",
29			cwd:  tmp,
30			want: "Read and understand everything in the current directory.",
31		},
32		{
33			name: "relative dir becomes a directory prompt",
34			arg:  "internal",
35			cwd:  tmp,
36			want: "Read and understand everything in the directory internal.",
37		},
38		{
39			name: "absolute dir under cwd is shown as a relative path",
40			arg:  subdir,
41			cwd:  tmp,
42			want: "Read and understand everything in the directory internal.",
43		},
44		{
45			name: "relative file becomes a file prompt",
46			arg:  "main.go",
47			cwd:  tmp,
48			want: "Read and understand the file main.go.",
49		},
50		{
51			name: "absolute file under cwd is shown as a relative path",
52			arg:  file,
53			cwd:  tmp,
54			want: "Read and understand the file main.go.",
55		},
56		{
57			name: "missing path falls back to the directory phrasing",
58			arg:  "does-not-exist",
59			cwd:  tmp,
60			want: "Read and understand everything in the directory does-not-exist.",
61		},
62		{
63			name: "absolute path outside cwd keeps its absolute form",
64			arg:  subdir,
65			cwd:  filepath.Join(tmp, "elsewhere"),
66			want: "Read and understand everything in the directory " + subdir + ".",
67		},
68		{
69			name: "leading and trailing whitespace are stripped",
70			arg:  "  main.go  ",
71			cwd:  tmp,
72			want: "Read and understand the file main.go.",
73		},
74	}
75
76	for _, tc := range cases {
77		t.Run(tc.name, func(t *testing.T) {
78			got := buildStudyPrompt(tc.arg, tc.cwd)
79			if got != tc.want {
80				t.Fatalf("buildStudyPrompt(%q, %q)\n  got:  %q\n  want: %q", tc.arg, tc.cwd, got, tc.want)
81			}
82		})
83	}
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 1

Tags 476

↑↓ moveenter openesc close