main 5041353

omnibox_entry_reconcile_test.go RawHistoryFolder

1package component
2
3import "testing"
4
5// reconcileEntryState decides how row-selected handlers resync the entry
6// buffer with the realInput/ghostSuffix shadow. The entry buffer is the source
7// of truth: search-changed is debounced (~150ms), so realInput lags behind
8// what the user actually typed. The old force-restore behavior rewrote the
9// buffer to the stale realInput, deleting characters typed during the
10// debounce window (fast typing dropped letters).
11func TestReconcileEntryState(t *testing.T) {
12	tests := []struct {
13		name          string
14		buffer        string
15		realInput     string
16		ghostSuffix   string
17		wantRealInput string
18		wantRewrite   bool
19	}{
20		{
21			name:          "ghost visible and untouched: strip it from the buffer",
22			buffer:        "google.com",
23			realInput:     "goo",
24			ghostSuffix:   "gle.com",
25			wantRealInput: "goo",
26			wantRewrite:   true,
27		},
28		{
29			name:          "buffer in sync, no ghost: nothing to do",
30			buffer:        "goo",
31			realInput:     "goo",
32			ghostSuffix:   "",
33			wantRealInput: "goo",
34			wantRewrite:   false,
35		},
36		{
37			name:          "user typed ahead of debounced realInput: buffer wins, never rewrite",
38			buffer:        "bne",
39			realInput:     "bn",
40			ghostSuffix:   "",
41			wantRealInput: "bne",
42			wantRewrite:   false,
43		},
44		{
45			name:          "user typed over the selected ghost suffix: buffer wins",
46			buffer:        "goog",
47			realInput:     "goo",
48			ghostSuffix:   "gle.com",
49			wantRealInput: "goog",
50			wantRewrite:   false,
51		},
52		{
53			name:          "stale ghost flag but buffer already shows real input only",
54			buffer:        "goo",
55			realInput:     "goo",
56			ghostSuffix:   "gle.com",
57			wantRealInput: "goo",
58			wantRewrite:   false,
59		},
60		{
61			name:          "user cleared the entry: buffer wins",
62			buffer:        "",
63			realInput:     "goo",
64			ghostSuffix:   "",
65			wantRealInput: "",
66			wantRewrite:   false,
67		},
68		{
69			name:          "empty ghost with empty input stays empty",
70			buffer:        "",
71			realInput:     "",
72			ghostSuffix:   "",
73			wantRealInput: "",
74			wantRewrite:   false,
75		},
76	}
77
78	for _, tt := range tests {
79		t.Run(tt.name, func(t *testing.T) {
80			gotRealInput, gotRewrite := reconcileEntryState(tt.buffer, tt.realInput, tt.ghostSuffix)
81			if gotRealInput != tt.wantRealInput {
82				t.Errorf("realInput = %q, want %q", gotRealInput, tt.wantRealInput)
83			}
84			if gotRewrite != tt.wantRewrite {
85				t.Errorf("rewrite = %v, want %v", gotRewrite, tt.wantRewrite)
86			}
87		})
88	}
89}

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