Add opt-in highlighting for TODO and FIXME comments - #3994
Open
Matei02355 wants to merge 2 commits into
Open
Conversation
Matei02355
marked this pull request as ready for review
September 7, 2026 17:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.