Skip to content

When creating multiple editors, the hoverDelegateFactory is a singleton causing an exception #22

@hcxw11

Description

@hcxw11

Steps to Reproduce:

  1. Create the editor via createEditor first, without triggering the cmd + f
  2. Create another diff editor in the same page via createDiffEditor and destroy the diff editor
  3. If you use the cmd + f shortcut in the editor created by createEditor, the editor cannot display the search for weight and throws the following error
Failed to execute command: Error: InstantiationService has been disposed
    at InstantiationService._throwIfDisposed (instantiationService.js:51:19)
    at InstantiationService.createInstance (instantiationService.js:92:14)
    at standaloneCodeEditor.js:77:89
    at createInstantHoverDelegate (hoverDelegateFactory.js:30:12)
    at new FindInput (findInput.js:63:72)
    at new ContextScopedFindInput (contextScopedHistoryWidget.js:66:9)
    at FindWidget._buildDomNode (findWidget.js:748:42)
    at new FindWidget (findWidget.js:107:14)
    at FindController._createFindWidget (findController.js:416:39)
    at FindController._start (findController.js:374:18)
    at FindController.start (findController.js:287:21)
    at Array.<anonymous> (findController.js:458:23)
    at MultiEditorAction.run (editorExtensions.js:285:35)
    at MultiEditorAction.runEditorCommand (editorExtensions.js:255:21)
    at codeEditorWidget.js:220:51
    at InstantiationService.invokeFunction (instantiationService.js:84:20)
    at InternalEditorAction._run (codeEditorWidget.js:219:51)
    at InternalEditorAction.run (editorAction.js:22:21)
    at MonacoActionRegistry.runAction (command.service.js:335:31)
    at Object.execute (command.service.js:321:33)
    at MonacoCommandRegistry.execute (command.service.js:150:50)
    at Object.execute (command.service.js:139:40)
    at CommandRegistryImpl.executeCommand (command.js:87:40) actions.find

Cause:

createEditor and createDiffEditor both use StandaloneCodeEditor, and there is setHoverDelegateFactory logic in constructor, where hoverDelegateFactory is a global singleton, which will be overwritten when the diff editor is created. So when I go back to the first editor and trigger the cmd + f shortcut, the hoverDelegateFactory on the singleton is from the diff editor, because the diff editor has been destroyed, so the InstantiationService is thrown here

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions