Skip to content

Make preview source matching path-safe across React fallback and definition lookup #4

Description

@rioredwards

Preview source matching still relies on string-prefix and substring checks, which can resolve the wrong file when repos share path prefixes or when separators differ across platforms.

Problem

  • src/reactFiberAdapter.ts uses substring-style matching for source file comparisons
  • src/hoverProvider.ts uses fsPath.startsWith(workspaceRoot) when filtering definition results
  • sibling repos such as /repo and /repo-other can be treated as the same workspace prefix
  • node_modules filtering only checks /node_modules/, which misses Windows-style paths

Suggested fix

  • Replace startsWith and substring checks with normalized, segment-aware path comparisons based on path.relative
  • Normalize separators before applying node_modules filtering
  • Add tests for /repo vs /repo-other, Windows-style paths, and same-basename files in different folders

Relevant files

  • src/reactFiberAdapter.ts
  • src/hoverProvider.ts
  • src/pathUtils.ts

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