From 3e0008ed785df0f3ce681aca16ecdf5ffc414b77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= Date: Tue, 3 Mar 2020 15:17:21 +0100 Subject: [PATCH] Update to work with latest monaco --- src/ts/RemoteCursorWidget.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/ts/RemoteCursorWidget.ts b/src/ts/RemoteCursorWidget.ts index 6dbd889..acb5e54 100644 --- a/src/ts/RemoteCursorWidget.ts +++ b/src/ts/RemoteCursorWidget.ts @@ -12,6 +12,21 @@ import {EditorContentManager} from "./EditorContentManager"; import {OnDisposed} from "./OnDisposed"; import {Validation} from "./Validation"; +interface Configuration { + readonly lineHeight: number; +} + +function getConfiguration(editorInstance: editor.ICodeEditor): Configuration { + // Support for Monaco < 0.19.0 + if (typeof (editorInstance as any).getConfiguration === 'function') { + return (editorInstance as any).getConfiguration() + } + + return { + lineHeight: editorInstance.getOption(editor.EditorOption.lineHeight) + }; +} + /** * This class implements a Monaco Content Widget to render a remote user's * cursor, and an optional tooltip. @@ -47,7 +62,7 @@ export class RemoteCursorWidget implements editor.IContentWidget, IDisposable { this._onDisposed = onDisposed; // Create the main node for the cursor element. - const {lineHeight} = this._editor.getConfiguration(); + const {lineHeight} = getConfiguration(this._editor); this._domNode = document.createElement("div"); this._domNode.className = "monaco-remote-cursor"; this._domNode.style.background = color;