Skip to content

CSS @media rule media features not searchable as symbols #2105

Description

@Widthdom

Summary

CSS @media rules contain feature queries (e.g., (min-width: 768px), (prefers-color-scheme: dark), (orientation: landscape)) that are not indexed. These query parameters are navigation anchors in responsive design workflows. Currently @media blocks themselves are indexed as "namespace", but the feature names and breakpoint values inside parentheses are invisible. Adding feature extraction would enable searches like "find all min-width usage" or "find dark mode styles".

Where

  • src/CodeIndex/Indexer/Symbols/SymbolExtractor.cs:1860 — CSS @media regex captures the opening but discards query details
  • src/CodeIndex/Indexer/Symbols/SymbolExtractor.Css.cs — No parsing of parenthesized feature expressions after @media keyword

Suggested approach

  1. Extract feature names (the identifiers and custom-property references inside @media parentheses) as separate "property" or "class" symbols
  2. For example, parse @media (min-width: 768px) and (prefers-color-scheme: dark) to yield symbols for min-width and prefers-color-scheme
  3. Handle boolean logic operators (and, or, not) correctly
  4. Skip feature values (e.g., 768px, dark) as they are literals, not identifiers
  5. Consider a separate symbol kind (e.g., "media-feature") if the distinction from regular properties is important for consumers
  6. Add tests for complex queries, operator precedence, and nesting inside @supports blocks

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