v0.38.1 969e52a

editor_ansi_prompt_test.go RawHistoryFolder

1package tui
2
3import (
4	"strings"
5	"testing"
6
7	"github.com/mattn/go-runewidth"
8)
9
10// TestEditor_AnsiPromptCursorAtEnd reproduces the live VS-Code drag
11// and drop bug: when the editor's Prompt carries ANSI styling (the
12// themed "▌ " glyph used by the interactive mode), the raw escape
13// bytes leaked into wrapLine's per-rune width counter, and the
14// cursor reported by Render() landed inside the wrapped row instead
15// of at the end. Render() must return a column equal to the visible
16// width of the last wrapped row when CursorC sits at end-of-buffer.
17func TestEditor_AnsiPromptCursorAtEnd(t *testing.T) {
18	// "\x1b[38;5;111m▌ \x1b[0m" is the exact prompt the interactive
19	// mode constructs via cfg.Theme.AccentBar. We hard-code the
20	// bytes here so the test doesn't depend on theme internals.
21	ansiPrompt := "\x1b[38;5;111m▌ \x1b[0m"
22
23	e := NewEditor(ansiPrompt)
24	// Same scenario as the captured live session: a screencaptureui
25	// temp path then " hello" typed afterwards.
26	pasted := "'/var/folders/xq/hdh5qm6j66nbzd0sh3ljsxyc0000gn/T/TemporaryItems/NSIRD_screencaptureui_P22eIV/Screenshot 2026-05-13 at 11.09.28.png'"
27	e.insert(pasted)
28	for _, r := range " hello" {
29		e.insert(string(r))
30	}
31
32	lines, row, col := e.Render(113)
33	if len(lines) == 0 {
34		t.Fatalf("Render returned no lines")
35	}
36	last := lines[len(lines)-1]
37	wantRow := len(lines) - 1
38	wantCol := runewidth.StringWidth(stripANSI(last))
39
40	if row != wantRow || col != wantCol {
41		t.Fatalf("cursor at row=%d col=%d, want row=%d col=%d\nrendered rows:\n%s",
42			row, col, wantRow, wantCol, strings.Join(lines, "\n"))
43	}
44}

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