Module CustomEditorProvider

Module CustomEditorProvider 

Source
Expand description

ยงCustomEditorProvider (Environment)

RESPONSIBILITIES:

  • Implements CustomEditorProvider for MountainEnvironment
  • 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 IPCProvider for RPC communication with Cocoon
  • Integrates with ApplicationState for provider registration persistence

ERROR HANDLING:

  • Uses CommonError for 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 service
  • vs/workbench/contrib/customEditor/common/customEditor.ts - custom editor interfaces
  • vs/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:

  • CustomEditorProvider implementation:
  • RegisterCustomEditorProvider - register extension provider
  • UnregisterCustomEditorProvider - unregister provider
  • OnSaveCustomDocument - save handler (stub)
  • ResolveCustomEditor - resolve editor content via RPC