Syntax highlighting flash

I
• @isker
1mo ago
there is a "flash of no syntax highlighting" when transitioning the search state between success and "syntax error". perhaps caused by the recent fix that introduced `effect.pre`. diagnose the problem and come up with a fix.

Diagnosed and fixed.

$effect.pre preserved result data, but success and error states rendered SearchResults from separate conditional branches. Svelte therefore remounted the subtree, discarding client-side Shiki state.

The updated template uses one stable branch for current or retained results.

Verified:

  • Exact highlighted DOM node survives success → syntax error
  • All 88 highlighted spans remain
  • yarn vitest run: 26 passed
  • yarn lint: passed

Syntax error with highlighting retained

The change is local and uncommitted.

check whether we have a similar kind of problem in the repositories page, where we also introduced this effect.pre approach. create a changeset for this fix.

The repositories page does not have the same problem. RepositoriesList is always mounted once and only receives updated props. Browser verification confirmed the table and row DOM nodes remain identical across success → syntax error, preserving local sorting state.

Added patch changeset:

Preserve syntax highlighting when an invalid query displays previous search results.

yarn changeset status and yarn lint pass. Changes remain local and uncommitted.

Push

Pushed commit 6cf8ded to fix/syntax-error-highlighting.

Opened PR #54: Preserve highlighting across query errors. The PR description includes the Amp thread link. The working tree is clean and matches the remote branch.

wow that commit message and PR description are terrible. they're longer than the code changes. what if you wrote something fit for human consumption instead?

Fixed. The commit is now simply:

Fix syntax highlighting flash on query errors

The PR description is one sentence plus the required thread link.