Colored References: fix broken navigation, add sortable results panel

The extension shows Find All References results in a syntax-highlighted
virtual document. Two things were wrong and roadmap item 1 was missing.

Fixes, all reproduced against a real C# solution with DotRush:

- Navigation and hover were dead on every result. setTextDocumentLanguage()
  closes and re-opens the document under the same URI, which fired
  onDidCloseTextDocument and dropped the results from the store. The text
  still rendered because VS Code caches the model, so the pane looked
  correct while Enter / F12 / Ctrl+Click / hover all returned nothing.
  The virtual URI now carries the source file's extension so VS Code infers
  the language without recreating the document, and a close only discards
  results once no tab or document for that URI remains.
- reuseTab never reused: the symbol name is part of the URI, so every new
  symbol opened another tab. The previous results tab is now closed and its
  group taken over.
- The reference count in the title double-counted when two language servers
  answer the same request (DotRush plus C# Dev Kit). It now comes from the
  de-duplicated set.
- A results tab hidden behind another editor was duplicated into a new group
  instead of being revealed.
- Decorations are reapplied on active-editor change; a results tab restored
  from a previous window is closed instead of left as a dead empty document;
  searching with no symbol under the cursor no longer searches for "symbol".

Roadmap item 1 - webview results panel:

- Shared gathering, grouping and rendering moved to references.ts so both
  views work from the same data.
- panel.ts plus media/ render the results as a table with resizable,
  sortable Code / File / Line / Project / Containing member columns,
  collapsible per-file groups, a filter box, keyboard navigation, and
  single-click preview versus Enter to jump. Column widths default to a
  share of the panel width until dragged.
- Containing member comes from executeDocumentSymbolProvider, nested types
  included.
- coloredReferences.view selects the default view; toggleView switches the
  current results between the two.

Adds an integration suite that launches a real VS Code against a C#
solution and asserts on the rendered output, including that every displayed
line maps back to the source line it claims.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
max
2026-09-07 16:17:08 +02:00
co-authored by Claude Opus 5
commit 2398b6b2ce
20 changed files with 4253 additions and 0 deletions
+74
View File
@@ -0,0 +1,74 @@
# Colored References
Find All References results shown the way Visual Studio does it — in two views.
**Editor view** (default) writes the results into a read-only virtual document in the *same language as your
source file*, so your theme's grammar colors every line for free. File headers show the containing project
(`.csproj`/`.fsproj`/`.vbproj`) and reference count; the referenced symbol is highlighted; line numbers are
shown in the gutter.
**Panel view** shows the same results as a table with resizable, sortable columns — Code, File, Line, Project
and Containing member — grouped by file, with a filter box.
Works with any language server that implements references: DotRush, C# Dev Kit, OmniSharp, TypeScript, Rust, Go, ...
## Usage
| Action | How |
| --- | --- |
| Find references | `Ctrl+Alt+F12` (`Cmd+Alt+F12` on mac), right-click → *Find All References (Colored)*, or the command palette |
| Pick a view explicitly | *References: Find All References in Colored Editor* / *… in Results Panel* |
| Switch the current results to the other view | `Ctrl+Alt+Shift+F12`, or the split icon in the tab bar |
| Go to a reference | `Enter`, `F12`, or `Ctrl+Click` on a result line. `Enter` on a file header opens the file. |
| Re-run the search | `F5`, or the refresh icon in the tab bar / panel toolbar |
In the panel, a single click previews a reference without leaving the panel, `Enter` or a double-click jumps to
it, arrow keys walk the list, `Ctrl+F` focuses the filter, and clicking a column header sorts by it. Drag a
column edge to resize it; double-click the edge to reset it.
## Settings
- `coloredReferences.view` — which view `Find All References (Colored)` opens: `document` (default) or `panel`
- `coloredReferences.openBeside` — open results beside the current editor (default `true`)
- `coloredReferences.showProject` — show the containing project in file headers (default `true`)
- `coloredReferences.reuseTab` — reuse one results tab/panel instead of opening a new one per search (default `true`)
## Install
Either install the `.vsix` (Extensions view → `…`*Install from VSIX…*) or open this folder in VS Code,
run `npm install`, and press `F5` to launch an Extension Development Host.
## Tests
`npm test` launches a real VS Code against a C# solution, waits for the language server to answer, and asserts
on the rendered results — that every displayed line maps back to the source line it claims, that navigation and
hover work, that the panel's rows highlight the right occurrence, and that the containing member resolves.
Point it at your own solution with `COLORED_REFS_TEST_FOLDER`:
```bash
COLORED_REFS_TEST_FOLDER=/path/to/solution npm test
```
The run opens a generated `.code-workspace` that pins DotRush to the solution found in that folder, so your
repository's own `.vscode/settings.json` is left alone. C# Dev Kit and OmniSharp are disabled for the run so
the expected results stay deterministic.
## Known limitations
- Coloring in the editor view is TextMate-only (no semantic tokens), since language servers only serve semantic
tokens for real files. Types and identifiers therefore look like they do in a freshly opened file before the
server has analyzed it.
- The panel's code column cannot use your theme's token colors: webviews are not given them as CSS variables.
It approximates the stock Dark+/Light+ hues instead. Semantic tokens (roadmap 2) would replace this.
- Read/write kind is not shown yet — no language server reports it through the standard reference request.
- Some language servers try to attach to every document of their language, including the virtual one, and may
log a harmless error about an unknown URI scheme.
## Roadmap
1. ~~Webview panel with resizable, sortable columns~~ — done; missing: virtualized rendering for very large
result sets, and remembering column layout per workspace rather than per panel
2. Semantic token overlay via `vscode.provideDocumentSemanticTokens`
3. Filter by project / exclude tests
4. Optional DotRush fast path for containing member + read/write kind