Support DocumentSymbolProvider in CustomTextEditor#304909
Support DocumentSymbolProvider in CustomTextEditor#304909jogibear9988 wants to merge 4 commits intomicrosoft:mainfrom
Conversation
|
implementation would look like this: |
There was a problem hiding this comment.
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
customEditorOutlineAPI surface (CustomEditorOutlineItem,CustomEditorOutlineProvider, andwindow.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. |
src/vs/workbench/contrib/customEditor/browser/customEditorOutline.ts
Outdated
Show resolved
Hide resolved
…Custom Editors can also populate the Outline view
a428452 to
de6741a
Compare
| return; | ||
| } | ||
| e.browserEvent.preventDefault(); | ||
| e.browserEvent.stopPropagation(); |
There was a problem hiding this comment.
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.
| e.browserEvent.stopPropagation(); | |
| e.browserEvent.stopPropagation(); | |
| tree.setSelection([e.element]); |
| 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; |
There was a problem hiding this comment.
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.

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
DocumentSymbolProvidercan work with.New API
The proposed API
customEditorOutlineadds:CustomEditorOutlineItem— describes a node in the outline tree withid,label,detail,tooltip,icon,contextValue, andchildren.CustomEditorOutlineProvider— interface withprovideOutline(),revealItem(),onDidChangeOutline, andonDidChangeActiveItem.window.registerCustomEditorOutlineProvider(viewType, provider)— registers the provider for a specific custom editor view type.Features
provideOutline()→ they appear in the Outline view with icons, labels, and a tree hierarchy.onDidChangeActiveItem→ the outline highlights/follows the active node.revealItem(id)is called so the extension can scroll the webview.customEditor/outline/toolbarwith"group": "inline"in theirpackage.json.customEditor/outline/toolbarwithout theinlinegroup.customEditor/outline/context(separate from the toolbar menu).customEditorOutlineItemcontext key is set to each item'scontextValue, enabling conditional menu contributions.Two Separate Menu Contribution Points
package.jsonMenuIdcustomEditor/outline/toolbarCustomEditorOutlineActionMenucustomEditor/outline/contextCustomEditorOutlineContextArchitecture
Files Changed
New files
src/vscode-dts/vscode.proposed.customEditorOutline.d.tssrc/vs/workbench/api/common/extHostCustomEditorOutline.tssrc/vs/workbench/api/browser/mainThreadCustomEditorOutline.tssrc/vs/workbench/contrib/customEditor/common/customEditorOutlineService.tssrc/vs/workbench/contrib/customEditor/browser/customEditorOutline.tsIOutlineimplementation with custom tree renderer andIOutlineCreatorModified files
src/vs/workbench/api/common/extHost.protocol.tssrc/vs/workbench/api/common/extHost.api.impl.tsregisterCustomEditorOutlineProvideronwindownamespacesrc/vs/platform/extensions/common/extensionsApiProposals.tscustomEditorOutlineproposalsrc/vs/platform/actions/common/actions.tsMenuId.CustomEditorOutlineActionMenuandMenuId.CustomEditorOutlineContextsrc/vs/workbench/services/actions/common/menusExtensionPoint.tscustomEditor/outline/toolbarandcustomEditor/outline/contextmenu contribution pointssrc/vs/workbench/services/outline/browser/outline.tscontextMenuIdandgetContextKeyOverlaytoIOutlineListConfigsrc/vs/workbench/contrib/outline/browser/outlinePane.tssrc/vs/workbench/contrib/customEditor/browser/customEditor.contribution.tssrc/vs/workbench/api/browser/extensionHost.contribution.tsmainThreadCustomEditorOutlineHow to Test
CustomTextEditorProvider)."enabledApiProposals": ["customEditorOutline"]to the extension'spackage.json.vscode.window.registerCustomEditorOutlineProvider(viewType, provider)with an implementation that returns outline items.revealItem().onDidChangeActiveItemhighlights the node in the outline.customEditor/outline/toolbar, verify inline buttons appear on hover and respond towhenclauses usingcustomEditorOutlineItem.customEditor/outline/context, verify the right-click context menu appears with the correct items filtered bywhenclauses.