Skip to content

Only highlight patterns inside comments #3

Description

@srbdev

Problem

Currently, patterns like TODO: are highlighted anywhere they appear in a file, including:

  • String literals: const msg = "TODO: fix this later"
  • Variable names: const TODO_CONFIG = {}
  • URLs or other content

This can create visual noise and false positives.

Proposed Solution

Use VS Code's DocumentSemanticTokensProvider or TokenInformation API to determine if a match is within a comment before applying the decoration.

Alternatively, use a simple heuristic: only highlight if the pattern appears after a comment prefix (//, #, /*, --, etc.) on the same line.

Trade-offs

  • Semantic tokens: More accurate, but depends on language support and may have performance implications
  • Heuristic: Simpler and faster, but may miss some edge cases (e.g., multi-line comments)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions