diff --git a/packages/plugin-ext/src/main/browser/editors-and-documents-main.ts b/packages/plugin-ext/src/main/browser/editors-and-documents-main.ts index ec7b87cc54f89..b089362763497 100644 --- a/packages/plugin-ext/src/main/browser/editors-and-documents-main.ts +++ b/packages/plugin-ext/src/main/browser/editors-and-documents-main.ts @@ -30,6 +30,7 @@ import { TextEditorsMainImpl } from './text-editors-main'; import { EditorManager } from '@theia/editor/lib/browser'; import { OpenerService } from '@theia/core/lib/browser/opener-service'; import { MonacoBulkEditService } from '@theia/monaco/lib/browser/monaco-bulk-edit-service'; +import { MonacoEditorService } from '@theia/monaco/lib/browser/monaco-editor-service'; export class EditorsAndDocumentsMain { private toDispose = new DisposableCollection(); @@ -57,11 +58,12 @@ export class EditorsAndDocumentsMain { const editorManager = container.get(EditorManager); const openerService = container.get(OpenerService); const bulkEditService = container.get(MonacoBulkEditService); + const monacoEditorService = container.get(MonacoEditorService); const documentsMain = new DocumentsMainImpl(this, this.modelService, rpc, editorManager, openerService); rpc.set(PLUGIN_RPC_CONTEXT.DOCUMENTS_MAIN, documentsMain); - const editorsMain = new TextEditorsMainImpl(this, rpc, bulkEditService); + const editorsMain = new TextEditorsMainImpl(this, rpc, bulkEditService, monacoEditorService); rpc.set(PLUGIN_RPC_CONTEXT.TEXT_EDITORS_MAIN, editorsMain); this.stateComputer = new EditorAndDocumentStateComputer(d => this.onDelta(d), editorService, this.modelService); diff --git a/packages/plugin-ext/src/main/browser/text-editors-main.ts b/packages/plugin-ext/src/main/browser/text-editors-main.ts index 8021dbb1fa595..cb5bf90929d3b 100644 --- a/packages/plugin-ext/src/main/browser/text-editors-main.ts +++ b/packages/plugin-ext/src/main/browser/text-editors-main.ts @@ -36,6 +36,7 @@ import { TextEditorMain } from './text-editor-main'; import { disposed } from '../../common/errors'; import { reviveWorkspaceEditDto } from './languages-main'; import { MonacoBulkEditService } from '@theia/monaco/lib/browser/monaco-bulk-edit-service'; +import { MonacoEditorService } from '@theia/monaco/lib/browser/monaco-editor-service'; export class TextEditorsMainImpl implements TextEditorsMain { @@ -44,8 +45,9 @@ export class TextEditorsMainImpl implements TextEditorsMain { private editorsToDispose = new Map(); constructor(private readonly editorsAndDocuments: EditorsAndDocumentsMain, - rpc: RPCProtocol, - private readonly bulkEditService: MonacoBulkEditService) { + rpc: RPCProtocol, + private readonly bulkEditService: MonacoBulkEditService, + private readonly monacoEditorService: MonacoEditorService) { this.proxy = rpc.getProxy(MAIN_RPC_CONTEXT.TEXT_EDITORS_EXT); this.toDispose.push(editorsAndDocuments.onTextEditorAdd(editors => editors.forEach(this.onTextEditorAdd, this))); this.toDispose.push(editorsAndDocuments.onTextEditorRemove(editors => editors.forEach(this.onTextEditorRemove, this))); @@ -108,9 +110,9 @@ export class TextEditorsMainImpl implements TextEditorsMain { } $tryApplyWorkspaceEdit(dto: WorkspaceEditDto): Promise { - const edits = reviveWorkspaceEditDto(dto); + const edits = reviveWorkspaceEditDto(dto); return new Promise(resolve => { - this.bulkEditService.apply( edits).then(() => resolve(true), err => resolve(false)); + this.bulkEditService.apply(edits).then(() => resolve(true), err => resolve(false)); }); } @@ -122,11 +124,11 @@ export class TextEditorsMainImpl implements TextEditorsMain { } $registerTextEditorDecorationType(key: string, options: DecorationRenderOptions): void { - monaco.services.StaticServices.codeEditorService.get().registerDecorationType(key, options); + this.monacoEditorService.registerDecorationType(key, options); } $removeTextEditorDecorationType(key: string): void { - monaco.services.StaticServices.codeEditorService.get().removeDecorationType(key); + this.monacoEditorService.removeDecorationType(key); } $trySetDecorations(id: string, key: string, ranges: DecorationOptions[]): Promise {