Skip to content

Commit

Permalink
[monaco] release leasking editor from quick open and goto references …
Browse files Browse the repository at this point in the history
…closures

Signed-off-by: Anton Kosyakov <[email protected]>
  • Loading branch information
akosyakov committed Apr 8, 2020
1 parent aa6f3f5 commit e1840a3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/monaco/src/browser/monaco-editor-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ export class MonacoEditorProvider {

const standaloneCommandService = new monaco.services.StandaloneCommandService(editor.instantiationService);
commandService.setDelegate(standaloneCommandService);
this.installQuickOpenService(editor);
this.installReferencesController(editor);
toDispose.push(this.installQuickOpenService(editor));
toDispose.push(this.installReferencesController(editor));

toDispose.push(editor.onFocusChanged(focused => {
if (focused) {
Expand Down Expand Up @@ -331,9 +331,10 @@ export class MonacoEditorProvider {
}
}

protected installQuickOpenService(editor: MonacoEditor): void {
protected installQuickOpenService(editor: MonacoEditor): Disposable {
const control = editor.getControl();
const quickOpenController = control._contributions['editor.controller.quickOpenController'];
const originalRun = quickOpenController.run;
quickOpenController.run = options => {
const selection = control.getSelection();
this.quickOpenService.internalOpen({
Expand All @@ -349,11 +350,13 @@ export class MonacoEditorProvider {
}
});
};
return Disposable.create(() => quickOpenController.run = originalRun);
}

protected installReferencesController(editor: MonacoEditor): void {
protected installReferencesController(editor: MonacoEditor): Disposable {
const control = editor.getControl();
const referencesController = control._contributions['editor.contrib.referencesController'];
const originalGotoReference = referencesController._gotoReference;
referencesController._gotoReference = async ref => {
if (referencesController._widget) {
referencesController._widget.hide();
Expand Down Expand Up @@ -402,6 +405,7 @@ export class MonacoEditorProvider {
monaco.error.onUnexpectedError(e);
});
};
return Disposable.create(() => referencesController._gotoReference = originalGotoReference);
}

getDiffNavigator(editor: TextEditor): DiffNavigator {
Expand Down

0 comments on commit e1840a3

Please sign in to comment.