Skip to content

Make missing-style Debug warning opt-in (closes #8) - #1

Merged
matrush merged 1 commit into
mainfrom
claude/peaceful-hawking-4qi4zc
Jun 22, 2026
Merged

matrush merged 1 commit into
mainfrom
claude/peaceful-hawking-4qi4zc

Conversation

@matrush

@matrush matrush commented Jun 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

Theme.applyStyleToString() emitted a #if DEBUG print() for every token whose style class is absent from the theme. Unstyled classes are normal theming behaviour — e.g. hljs-operator intentionally inherits the default colour under atom-one-light/atom-one-dark — so this fired thousands of times per highlighting pass (~5,585 prints / ~167ms in the reported case), spamming the console and noticeably degrading Debug-mode highlighting performance.

This implements option 2 from the issue: gate the warning behind an opt-in flag rather than removing it, so the diagnostic is still available when developing a custom theme.

Changes

  • Add public var logsMissingStyles: Bool = false to Theme.
  • Only emit the WARNING MISSING STYLE… print when logsMissingStyles is true (still #if DEBUG-gated, so Release builds are unchanged).
  • Document the flag in the README and add a usage example.
  • Add a CHANGELOG entry and bump the version to 3.1.1.

Usage

highlighter.theme.logsMissingStyles = true   // off by default

Closes smittytone#8.

🤖 Generated with Claude Code


The Theme.applyStyleToString() method emitted a DEBUG print() for every
token whose style class is absent from the theme. Unstyled classes (eg.
hljs-operator under atom-one-light/dark) are normal theming behaviour, so
this fired thousands of times per highlighting pass, spamming the console
and noticeably slowing Debug-mode highlighting.

Gate the warning behind a new opt-in Theme.logsMissingStyles flag
(default false). Document it in the README and CHANGELOG, and bump the
version to 3.1.1.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01URhepimagEqZ2kCNzyQcYU
@matrush
matrush merged commit ae497e9 into main Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DEBUG print() per token for unstyled classes (e.g. hljs-operator with atom-one) — console spam + slow Debug highlighting

2 participants