Skip to content

Commit 6384d96

Browse files
LetZicot3dotgg
authored andcommitted
fix(web): cover the SSR settings preview highlighter site; trim engine comment
Macroscope review: SettingsFontPreviews' preloadPatchFile call reaches DiffHunksRenderer.initializeHighlighter, which creates the shared first-caller-wins singleton with the library's shiki-js default. Opening Appearance settings before any diff/file surface would pin the JS regex engine for the whole session. Pass PREFERRED_HIGHLIGHTER there too, and trim the incident detail out of the constant's doc comment.
1 parent 5f15603 commit 6384d96

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

‎apps/web/src/components/settings/SettingsFontPreviews.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { terminalThemeFromApp } from "../ThreadTerminalDrawer";
55
import { useTheme } from "../../hooks/useTheme";
66
import { DISCONNECTED_COMPOSER_PLACEHOLDER } from "../../composerPlaceholder";
77
import { resolveDiffThemeName, type DiffThemeName } from "../../lib/diffRendering";
8+
import { PREFERRED_HIGHLIGHTER } from "../../lib/syntaxHighlighting";
89
import { GhosttyTerminalSurface } from "~/terminal/ghostty/surface";
910

1011
// The font previews are the real surfaces, not lookalikes: the composer's
@@ -79,7 +80,7 @@ function loadDiffPreviewHtml(theme: DiffThemeName): Promise<readonly string[]> {
7980
if (promise === undefined) {
8081
promise = preloadPatchFile({
8182
patch: DIFF_PREVIEW_PATCH,
82-
options: { diffStyle: "unified", theme },
83+
options: { diffStyle: "unified", theme, preferredHighlighter: PREFERRED_HIGHLIGHTER },
8384
}).then((results) => results.map((result) => result.prerenderedHTML));
8485
diffPreviewHtmlByTheme.set(theme, promise);
8586
}

‎apps/web/src/lib/syntaxHighlighting.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ import {
88
import { resolveDiffThemeName } from "./diffRendering";
99

1010
/**
11-
* Always highlight with the Oniguruma WASM engine. The JavaScript regex engine
12-
* can backtrack catastrophically on ordinary source lines (a Go comment
13-
* containing `{}` and a non-ASCII dash pinned the renderer main thread for 12+
14-
* minutes; the same input tokenizes in under 10ms on WASM). The shared
11+
* Always highlight with the Oniguruma WASM engine — the JS regex engine can
12+
* backtrack catastrophically and hang the tokenizing thread. The shared
1513
* highlighter is a first-caller-wins singleton, so every creation site must
1614
* pass this value.
1715
*/

0 commit comments

Comments
 (0)