Skip to content

Conversation

@sumimakito
Copy link

@sumimakito sumimakito commented Dec 20, 2025

Description

Currently, getDefaultHoverDelegate and createInstantHoverDelegate are still used in many places across the codebase. While getDefaultHoverDelegate returns a lazy-initialized IScopedHoverDelegate, createInstantHoverDelegate calls the internally captured hoverDelegateFactory set by setHoverDelegateFactory to create an IScopedHoverDelegate.

After the StandaloneCodeEditor (created via monaco.editor.create) calls setHoverDelegateFactory on initialization, the StandaloneDiffEditor2 (created via monaco.editor.createDiffEditor) calls it a second time and overwrites it with a different HoverDelegateFactory. After the StandaloneDiffEditor2 is disposed, the last HoverDelegateFactory it set still captures a disposed InstantiationService, which causes an error upon use.

Fixes microsoft/monaco-editor#4612

Reproduction

Open in the Monaco Editor Playground

Monaco-Editor-Repro.mp4

Copilot AI review requested due to automatic review settings December 20, 2025 08:34
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 fixes a bug where the hover delegate factory could capture a disposed instantiation service, causing errors when hovering after a diff editor is disposed.

Key Changes:

  • Changed setHoverDelegateFactory in StandaloneCodeEditor to use the singleton StandaloneServices.initialize({}) instead of the injected instantiationService parameter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Error: InstantiationService has been disposed

2 participants