Expand description
ยงCustomEditorProvider (Environment)
RESPONSIBILITIES:
- Implements
CustomEditorProviderforMountainEnvironment - Manages registration and lifecycle of custom non-text editors
- Coordinates Webview-based editing experiences (SVG editors, diff viewers, etc.)
- Handles editor resolution, save operations, and provider unregistration
ARCHITECTURAL ROLE:
- Environment provider that enables extension-contributed custom editors
- Uses
IPCProviderfor RPC communication with Cocoon - Integrates with
ApplicationStatefor provider registration persistence
ERROR HANDLING:
- Uses
CommonErrorfor all operations - ViewType validation: rejects empty view types with InvalidArgument error
- Some operations are stubbed with logging/warning (OnSaveCustomDocument)
PERFORMANCE:
- Provider registration lookup should be O(1) via hash map in ApplicationState (TODO)
- ResolveCustomEditor uses fire-and-forget RPC pattern to avoid waiting
VS CODE REFERENCE:
vs/workbench/contrib/customEditor/browser/customEditorService.ts- custom editor servicevs/workbench/contrib/customEditor/common/customEditor.ts- custom editor interfacesvs/platform/workspace/common/workspace.ts- resource URI handling
TODO:
- Store provider registrations in ApplicationState with capability metadata
- Implement custom editor backup/restore mechanism
- Add support for multiple active instances of the same viewType
- Implement custom editor move and rename handling
- Add proper validation of viewType and resource URI
- Implement editor-specific command registration
- Add support for custom editor dispose/cleanup
- Consider adding editor state persistence across reloads
- Implement proper error recovery for Webview crashes
- Add telemetry for custom editor usage metrics
MODULE CONTENTS:
CustomEditorProviderimplementation:RegisterCustomEditorProvider- register extension providerUnregisterCustomEditorProvider- unregister providerOnSaveCustomDocument- save handler (stub)ResolveCustomEditor- resolve editor content via RPC