Skip to content

Add opt-in highlighting for TODO and FIXME comments - #3994

Open
Matei02355 wants to merge 2 commits into
sharkdp:masterfrom
Matei02355:highlight-comment-todos-2225-20260907
Open

Add opt-in highlighting for TODO and FIXME comments#3994
Matei02355 wants to merge 2 commits into
sharkdp:masterfrom
Matei02355:highlight-comment-todos-2225-20260907

Conversation

@Matei02355

Copy link
Copy Markdown
Contributor

TODO and FIXME annotations currently inherit ordinary comment colors and are easy to miss.

Add --highlight-todos and PrettyPrinter::highlight_todos. Use syntax comment scopes to emphasize TODO, TODOS, FIXME and FIXMES, ignoring case, from the marker to the end of its comment on that line. Leave strings, ordinary code and subsequent block-comment lines unchanged. Support comments inside embedded languages without patching every grammar.

Keep the normal highlighter when the option is disabled. When enabled, parse each line once and retain a comment scope stack alongside the normal highlight state. Apply bold amber while preserving existing background and other font attributes; use darker amber on light themes and terminal yellow for palette-based themes. Preserve source bytes, line endings, range behavior and the existing long-line highlighting limit. The option requires colored output and is disabled by default.

Validation: the full all-feature suite passed 485 tests (7 ignored), including eight scope-level and four CLI/library regressions. Those 12 tests also passed after replacing the marker regex with the existing Unicode word-segmentation dependency so minimal library builds need no additional dependency. Coverage includes Rust, Python, Bash, JavaScript, CSS, SQL, HTML, Markdown embedding, Unicode, word boundaries, CR/LF/CRLF, wrapping, line ranges, strings, plain text, light/palette themes and long lines. All 8 default-feature help tests passed. All-target/all-feature Clippy with warnings denied, the minimal library build, formatting, whitespace checks and Bash/Zsh completion syntax passed.

README, manual, help and all four completions are updated.

Fixes #2225.

@Matei02355
Matei02355 marked this pull request as ready for review September 7, 2026 17:46
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.

Feature Request: Highlight TODOs

1 participant