v0.31.0 9467429

markdown_test.go RawHistoryFolder

1package tui
2
3import (
4	"strings"
5	"testing"
6)
7
8func TestRenderMarkdownTableWrapsToWidth(t *testing.T) {
9	in := strings.Join([]string{
10		"| Area | What’s visible | Summary |",
11		"| --- | --- | --- |",
12		"| Overall UI | Dark terminal/TUI-style interface | A screenshot of an AI/coding-agent session, likely inside zut or a similar terminal app. |",
13		"| Main content | Markdown-formatted response | The assistant is describing what was seen in a previous screenshot. |",
14	}, "\n")
15	out := RenderMarkdown(in, Dark, 80)
16	plain := stripANSI(out)
17	lines := strings.Split(plain, "\n")
18	if len(lines) <= 4 {
19		t.Fatalf("expected wrapped table rows, got:\n%s", plain)
20	}
21	for i, line := range lines {
22		if visibleWidth(line) > 80 {
23			t.Fatalf("line %d width %d > 80: %q\n%s", i, visibleWidth(line), line, plain)
24		}
25	}
26	want := pipePositions(lines[0])
27	for i, line := range lines[1:] {
28		if got := pipePositions(line); !equalInts(got, want) {
29			t.Fatalf("line %d pipe columns %v, want %v: %q\n%s", i+1, got, want, line, plain)
30		}
31	}
32}
33
34func TestRenderMarkdownTableAlignsColumns(t *testing.T) {
35	in := strings.Join([]string{
36		"| Tool | Core-Sprache | Runtime/Distribution |",
37		"| --- | --- | --- |",
38		"| Claude Code | TypeScript | Node.js |",
39		"| Codex CLI | Rust | Natives Binary (npm-Wrapper) |",
40		"| OpenCode | TypeScript (+ Go für TUI) | Bun, kompiliertes Binary |",
41		"| zut | Go | Natives Binary |",
42	}, "\n")
43	out := RenderMarkdown(in, Dark, 80)
44	plain := stripANSI(out)
45	lines := strings.Split(plain, "\n")
46	if len(lines) != 6 {
47		t.Fatalf("got %d lines:\n%s", len(lines), plain)
48	}
49	counts := make([]int, len(lines))
50	for i, line := range lines {
51		counts[i] = strings.Count(line, "|")
52		if counts[i] != 4 {
53			t.Fatalf("line %d has %d pipes, want 4: %q\n%s", i, counts[i], line, plain)
54		}
55	}
56	// Every pipe column should line up across all rows.
57	want := pipePositions(lines[0])
58	for i, line := range lines[1:] {
59		if got := pipePositions(line); !equalInts(got, want) {
60			t.Fatalf("line %d pipe columns %v, want %v: %q\n%s", i+1, got, want, line, plain)
61		}
62	}
63}
64
65func pipePositions(s string) []int {
66	var out []int
67	for i, r := range []rune(s) {
68		if r == '|' {
69			out = append(out, i)
70		}
71	}
72	return out
73}
74
75func equalInts(a, b []int) bool {
76	if len(a) != len(b) {
77		return false
78	}
79	for i := range a {
80		if a[i] != b[i] {
81			return false
82		}
83	}
84	return true
85}

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