v0.27.0 dcb4c51

omnibox_ghost_state_test.go RawHistoryFolder

1package component
2
3import "testing"
4
5func TestInlineGhostSelection(t *testing.T) {
6	tests := []struct {
7		name           string
8		realInput      string
9		ghostFullText  string
10		selectionStart int
11		selectionEnd   int
12		hasSelection   bool
13		want           bool
14	}{
15		{
16			name:           "selected suffix matches typed prefix",
17			realInput:      "goo",
18			ghostFullText:  "google.com",
19			selectionStart: 3,
20			selectionEnd:   10,
21			hasSelection:   true,
22			want:           true,
23		},
24		{
25			name:           "no selection means no ghost suffix",
26			realInput:      "goo",
27			ghostFullText:  "google.com",
28			selectionStart: 10,
29			selectionEnd:   10,
30			hasSelection:   false,
31			want:           false,
32		},
33		{
34			name:           "collapsed selection should not be treated as ghost",
35			realInput:      "goo",
36			ghostFullText:  "google.com",
37			selectionStart: 10,
38			selectionEnd:   10,
39			hasSelection:   true,
40			want:           false,
41		},
42		{
43			name:           "wrong selection range should not be treated as ghost",
44			realInput:      "goo",
45			ghostFullText:  "google.com",
46			selectionStart: 1,
47			selectionEnd:   10,
48			hasSelection:   true,
49			want:           false,
50		},
51	}
52
53	for _, tt := range tests {
54		t.Run(tt.name, func(t *testing.T) {
55			got := isInlineGhostSelection(
56				tt.realInput,
57				tt.ghostFullText,
58				tt.selectionStart,
59				tt.selectionEnd,
60				tt.hasSelection,
61			)
62			if got != tt.want {
63				t.Fatalf("isInlineGhostSelection() = %v, want %v", got, tt.want)
64			}
65		})
66	}
67}
68
69func TestAcceptedGhostInput(t *testing.T) {
70	tests := []struct {
71		name          string
72		hasGhost      bool
73		ghostFullText string
74		wantText      string
75		wantAccepted  bool
76	}{
77		{
78			name:          "accepts explicit ghost",
79			hasGhost:      true,
80			ghostFullText: "google.com",
81			wantText:      "google.com",
82			wantAccepted:  true,
83		},
84		{
85			name:          "rejects without ghost",
86			hasGhost:      false,
87			ghostFullText: "google.com",
88			wantText:      "",
89			wantAccepted:  false,
90		},
91		{
92			name:          "rejects empty ghost text",
93			hasGhost:      true,
94			ghostFullText: "",
95			wantText:      "",
96			wantAccepted:  false,
97		},
98	}
99
100	for _, tt := range tests {
101		t.Run(tt.name, func(t *testing.T) {
102			gotText, gotAccepted := acceptedGhostInput(tt.hasGhost, tt.ghostFullText)
103			if gotText != tt.wantText {
104				t.Fatalf("acceptedGhostInput() text = %q, want %q", gotText, tt.wantText)
105			}
106			if gotAccepted != tt.wantAccepted {
107				t.Fatalf("acceptedGhostInput() accepted = %v, want %v", gotAccepted, tt.wantAccepted)
108			}
109		})
110	}
111}

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