detached 6b98b2a

fix(tui): key terminal syntax cache by roles

commit
6b98b2a54f5d6b8ab3974698ba0a7e32b23092b9
author
brice · · 2026-08-23 15:48 UTC
parent
037ba94
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +25 -1
M packages/tui/highlight.go +9 -1
@@ -411,7 +411,15 @@ func (th Theme) terminalSyntaxKeyPart() string {
411411 for _, color := range th.Terminal.Palette {
412412 h = hashThemeColor(h, color)
413413 }
414- for _, color := range []TerminalColor{th.Terminal.Foreground, th.Terminal.Background} {
414+ for _, color := range []TerminalColor{
415+ th.Terminal.Foreground,
416+ th.Terminal.Background,
417+ th.Accent,
418+ th.Muted,
419+ th.Tool,
420+ th.Warning,
421+ th.Error,
422+ } {
415423 h = hashThemeColor(h, color)
416424 }
417425 for _, value := range []bool{th.Terminal.HasForeground, th.Terminal.HasBackground, th.Terminal.TrueColor, th.Terminal.Light, th.Terminal.SchemeKnown} {
@@ -411,7 +411,15 @@ func (th Theme) terminalSyntaxKeyPart() string {
411 for _, color := range th.Terminal.Palette {411 for _, color := range th.Terminal.Palette {
412 h = hashThemeColor(h, color)412 h = hashThemeColor(h, color)
413 }413 }
414- for _, color := range []TerminalColor{th.Terminal.Foreground, th.Terminal.Background} {414+ for _, color := range []TerminalColor{
415+ th.Terminal.Foreground,
416+ th.Terminal.Background,
417+ th.Accent,
418+ th.Muted,
419+ th.Tool,
420+ th.Warning,
421+ th.Error,
422+ } {
415 h = hashThemeColor(h, color)423 h = hashThemeColor(h, color)
416 }424 }
417 for _, value := range []bool{th.Terminal.HasForeground, th.Terminal.HasBackground, th.Terminal.TrueColor, th.Terminal.Light, th.Terminal.SchemeKnown} {425 for _, value := range []bool{th.Terminal.HasForeground, th.Terminal.HasBackground, th.Terminal.TrueColor, th.Terminal.Light, th.Terminal.SchemeKnown} {
M packages/tui/highlight_terminal_test.go +16 -0
@@ -28,6 +28,22 @@ func TestTerminalSyntaxUsesReportedRGBPalette(t *testing.T) {
2828 }
2929 }
3030
31+func TestTerminalSyntaxCacheIncludesSemanticRoles(t *testing.T) {
32+ profile := TerminalProfile{Depth: ColorDepthTrueColor}
33+ first := TerminalTheme(profile)
34+ first.Accent = ColorRGB(1, 2, 3)
35+ second := TerminalTheme(profile)
36+ second.Accent = ColorRGB(4, 5, 6)
37+
38+ const source = "func terminalSyntaxCacheSentinel() {}"
39+ if got := strings.Join(first.HighlightCode(source, "go"), "\n"); !strings.Contains(got, "\x1b[38;2;1;2;3m") {
40+ t.Fatalf("first output = %q, want first accent", got)
41+ }
42+ if got := strings.Join(second.HighlightCode(source, "go"), "\n"); !strings.Contains(got, "\x1b[38;2;4;5;6m") {
43+ t.Fatalf("second output reused first semantic color: %q", got)
44+ }
45+}
46+
3147 func TestTerminalSyntaxHonorsCustomOverrides(t *testing.T) {
3248 th := TerminalTheme(TerminalProfile{Depth: ColorDepthTrueColor})
3349 th.Syntax.Keyword = "#112233 bold"
@@ -28,6 +28,22 @@ func TestTerminalSyntaxUsesReportedRGBPalette(t *testing.T) {
28 }28 }
29 }29 }
30 30
31+func TestTerminalSyntaxCacheIncludesSemanticRoles(t *testing.T) {
32+ profile := TerminalProfile{Depth: ColorDepthTrueColor}
33+ first := TerminalTheme(profile)
34+ first.Accent = ColorRGB(1, 2, 3)
35+ second := TerminalTheme(profile)
36+ second.Accent = ColorRGB(4, 5, 6)
37+
38+ const source = "func terminalSyntaxCacheSentinel() {}"
39+ if got := strings.Join(first.HighlightCode(source, "go"), "\n"); !strings.Contains(got, "\x1b[38;2;1;2;3m") {
40+ t.Fatalf("first output = %q, want first accent", got)
41+ }
42+ if got := strings.Join(second.HighlightCode(source, "go"), "\n"); !strings.Contains(got, "\x1b[38;2;4;5;6m") {
43+ t.Fatalf("second output reused first semantic color: %q", got)
44+ }
45+}
46+
31 func TestTerminalSyntaxHonorsCustomOverrides(t *testing.T) {47 func TestTerminalSyntaxHonorsCustomOverrides(t *testing.T) {
32 th := TerminalTheme(TerminalProfile{Depth: ColorDepthTrueColor})48 th := TerminalTheme(TerminalProfile{Depth: ColorDepthTrueColor})
33 th.Syntax.Keyword = "#112233 bold"49 th.Syntax.Keyword = "#112233 bold"

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