Skip to content

Support DocumentSymbolProvider in CustomTextEditor#304909

Open
jogibear9988 wants to merge 4 commits intomicrosoft:mainfrom
jogibear9988:customEditorOutline
Open

Support DocumentSymbolProvider in CustomTextEditor#304909
jogibear9988 wants to merge 4 commits intomicrosoft:mainfrom
jogibear9988:customEditorOutline

Conversation

@jogibear9988
Copy link
Contributor

Support DocumentSymbolProvider in CustomTextEditor

Fixes #97095

Description

This PR adds a proposed extension API that allows Custom Editor extensions to provide outline data for the Outline view, Breadcrumbs, and Go to Symbol quick-pick. Previously, custom editors had no way to contribute to these features since they don't use a standard text model that a DocumentSymbolProvider can work with.

New API

The proposed API customEditorOutline adds:

  • CustomEditorOutlineItem — describes a node in the outline tree with id, label, detail, tooltip, icon, contextValue, and children.
  • CustomEditorOutlineProvider — interface with provideOutline(), revealItem(), onDidChangeOutline, and onDidChangeActiveItem.
  • window.registerCustomEditorOutlineProvider(viewType, provider) — registers the provider for a specific custom editor view type.

Features

  • Outline tree: Extension provides items via provideOutline() → they appear in the Outline view with icons, labels, and a tree hierarchy.
  • Active element tracking: Extension fires onDidChangeActiveItem → the outline highlights/follows the active node.
  • Reveal on click: User clicks an outline node → revealItem(id) is called so the extension can scroll the webview.
  • Breadcrumbs: Automatically built from the active item's parent chain.
  • Go to Symbol: Items appear in the Ctrl+Shift+O quick-pick.
  • Inline toolbar buttons: Extensions contribute to customEditor/outline/toolbar with "group": "inline" in their package.json.
  • Overflow menu: Extensions contribute to customEditor/outline/toolbar without the inline group.
  • Right-click context menu: Extensions contribute to customEditor/outline/context (separate from the toolbar menu).
  • When clauses: The customEditorOutlineItem context key is set to each item's contextValue, enabling conditional menu contributions.

Two Separate Menu Contribution Points

Menu ID in package.json Internal MenuId Purpose
customEditor/outline/toolbar CustomEditorOutlineActionMenu Inline icon buttons + "..." overflow dropdown
customEditor/outline/context CustomEditorOutlineContext Right-click context menu

Architecture

Extension Host                    Main Thread
─────────────────                 ──────────────────────────────
ExtHostCustomEditorOutline  ←RPC→  MainThreadCustomEditorOutline
                                          │
                                          ▼
                                  ICustomEditorOutlineProviderService
                                          │
                                          ▼
                                  CustomEditorExtensionOutline (IOutline<>)
                                          │
                                          ▼
                                  OutlinePane / Breadcrumbs / QuickPick

Files Changed

New files

File Purpose
src/vscode-dts/vscode.proposed.customEditorOutline.d.ts Proposed API types
src/vs/workbench/api/common/extHostCustomEditorOutline.ts Extension host implementation
src/vs/workbench/api/browser/mainThreadCustomEditorOutline.ts Main thread handler + provider service + singleton
src/vs/workbench/contrib/customEditor/common/customEditorOutlineService.ts Service interface and DTO type
src/vs/workbench/contrib/customEditor/browser/customEditorOutline.ts IOutline implementation with custom tree renderer and IOutlineCreator

Modified files

File Change
src/vs/workbench/api/common/extHost.protocol.ts Protocol shapes and proxy identifiers
src/vs/workbench/api/common/extHost.api.impl.ts Wired registerCustomEditorOutlineProvider on window namespace
src/vs/platform/extensions/common/extensionsApiProposals.ts Registered customEditorOutline proposal
src/vs/platform/actions/common/actions.ts Added MenuId.CustomEditorOutlineActionMenu and MenuId.CustomEditorOutlineContext
src/vs/workbench/services/actions/common/menusExtensionPoint.ts Registered customEditor/outline/toolbar and customEditor/outline/context menu contribution points
src/vs/workbench/services/outline/browser/outline.ts Added contextMenuId and getContextKeyOverlay to IOutlineListConfig
src/vs/workbench/contrib/outline/browser/outlinePane.ts Added right-click context menu support using context key overlays
src/vs/workbench/contrib/customEditor/browser/customEditor.contribution.ts Import to register the outline creator
src/vs/workbench/api/browser/extensionHost.contribution.ts Import for mainThreadCustomEditorOutline

How to Test

  1. Use an extension that registers a custom editor (e.g. a visual designer with CustomTextEditorProvider).
  2. Add "enabledApiProposals": ["customEditorOutline"] to the extension's package.json.
  3. Call vscode.window.registerCustomEditorOutlineProvider(viewType, provider) with an implementation that returns outline items.
  4. Open a file handled by the custom editor.
  5. Verify the Outline view shows the items from the provider with correct icons, labels, and hierarchy.
  6. Verify clicking an outline node calls revealItem().
  7. Verify firing onDidChangeActiveItem highlights the node in the outline.
  8. Verify Breadcrumbs shows the active item's parent chain.
  9. Verify Ctrl+Shift+O shows the items in the quick-pick.
  10. If the extension contributes to customEditor/outline/toolbar, verify inline buttons appear on hover and respond to when clauses using customEditorOutlineItem.
  11. If the extension contributes to customEditor/outline/context, verify the right-click context menu appears with the correct items filtered by when clauses.

Copilot AI review requested due to automatic review settings March 25, 2026 21:26
@vs-code-engineering vs-code-engineering bot added this to the 1.114.0 milestone Mar 25, 2026
@jogibear9988
Copy link
Contributor Author

see:

image

@jogibear9988
Copy link
Contributor Author

implementation would look like this:

node-projects/vs-code-designer-addon#12

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new proposed API (customEditorOutline) that lets Custom Editor extensions provide outline data so VS Code can populate the Outline view, Breadcrumbs, and Go to Symbol for custom editors that don’t use a standard text model.

Changes:

  • Adds the proposed customEditorOutline API surface (CustomEditorOutlineItem, CustomEditorOutlineProvider, and window.registerCustomEditorOutlineProvider).
  • Implements ext host ↔ main thread plumbing plus a workbench-side IOutline<> implementation for custom editors, including per-item toolbar and context menu contribution points.
  • Extends the outline infrastructure to support per-outline context menus and context key overlays.

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/vscode-dts/vscode.proposed.customEditorOutline.d.ts Adds the proposed extension API types and registration function.
src/vs/workbench/services/outline/browser/outline.ts Extends outline config to support context menus + per-element context key overlays.
src/vs/workbench/services/actions/common/menusExtensionPoint.ts Registers new proposed menu contribution points for custom editor outline toolbar/context menus.
src/vs/workbench/contrib/outline/browser/outlinePane.ts Adds generic right-click context menu handling for outlines that opt in.
src/vs/workbench/contrib/customEditor/common/customEditorOutlineService.ts Defines the provider service contract and DTO shape.
src/vs/workbench/contrib/customEditor/browser/customEditorOutline.ts Implements the custom-editor-backed IOutline<> and registers an outline creator.
src/vs/workbench/contrib/customEditor/browser/customEditor.contribution.ts Ensures the custom editor outline contribution is loaded.
src/vs/workbench/api/common/extHostCustomEditorOutline.ts Ext host implementation: registers providers and converts outline items to DTOs.
src/vs/workbench/api/common/extHost.protocol.ts Adds RPC shapes and proxy identifiers for custom editor outline support.
src/vs/workbench/api/common/extHost.api.impl.ts Exposes window.registerCustomEditorOutlineProvider in the ext host API surface.
src/vs/workbench/api/browser/mainThreadCustomEditorOutline.ts Main thread handler + singleton service bridging to the ext host provider.
src/vs/workbench/api/browser/extensionHost.contribution.ts Wires the main thread participant into extension host contributions.
src/vs/platform/extensions/common/extensionsApiProposals.ts Registers the customEditorOutline proposal name.
src/vs/platform/actions/common/actions.ts Adds MenuIds for the custom editor outline toolbar and context menus.
custom-editor-outline.md Adds documentation for the new proposed API and menu contribution points.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 15 changed files in this pull request and generated 2 comments.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 15 changed files in this pull request and generated 2 comments.

return;
}
e.browserEvent.preventDefault();
e.browserEvent.stopPropagation();
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The context-menu handler focuses the element under the cursor but does not update the tree selection. This can lead to the UI showing a different selected row than the one the menu applies to, and it differs from the selection behavior used in other tree context menus. Consider also calling tree.setSelection([e.element]) (or mirroring the "ensure clicked item is selected" logic used elsewhere) before showing the menu.

Suggested change
e.browserEvent.stopPropagation();
e.browserEvent.stopPropagation();
tree.setSelection([e.element]);

Copilot uses AI. Check for mistakes.
Comment on lines +29 to +33
hasProvider(viewType: string): boolean;
getProviderViewTypes(): string[];
provideOutline(viewType: string, token: CancellationToken): Promise<ICustomEditorOutlineItemDto[] | undefined>;
revealItem(viewType: string, itemId: string): void;
getActiveItemId(viewType: string): string | undefined;
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ICustomEditorOutlineProviderService.provideOutline/revealItem are keyed only by viewType. This makes it impossible to reliably support multiple open custom editors of the same viewType (e.g. split editor groups / breadcrumbs), because the provider cannot know which editor/resource the request targets. Consider threading a per-editor identifier through the service (e.g. resource: URI or a generated editor handle) for provide/reveal/active-item/events so outline instances don’t conflict.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support DocumentSymbolProvider in CustomTextEditor

3 participants