From 968b777753c2a2bad30fd05b954b0d1f6f6dcc0c Mon Sep 17 00:00:00 2001 From: Brendan Powers Date: Tue, 23 Feb 2021 12:03:20 -0800 Subject: [PATCH 1/2] Handle case where getCursor() returns null in highlighter --- packages/jupyterlab-lsp/src/features/highlights.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/jupyterlab-lsp/src/features/highlights.ts b/packages/jupyterlab-lsp/src/features/highlights.ts index 165091381..35c09a7b9 100644 --- a/packages/jupyterlab-lsp/src/features/highlights.ts +++ b/packages/jupyterlab-lsp/src/features/highlights.ts @@ -145,6 +145,11 @@ export class HighlightsCM extends CodeMirrorIntegration { return; } + if (!root_position) { + this.console.warn('no root position available'); + return; + } + const token = this.virtual_editor.get_token_at(root_position); // if token has not changed, no need to update highlight, unless it is an empty token From 4893e3ef575a662727da108dcccd670e5bed717e Mon Sep 17 00:00:00 2001 From: Brendan Powers Date: Tue, 23 Feb 2021 14:03:29 -0800 Subject: [PATCH 2/2] Clean up null check --- packages/jupyterlab-lsp/src/features/highlights.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/jupyterlab-lsp/src/features/highlights.ts b/packages/jupyterlab-lsp/src/features/highlights.ts index 35c09a7b9..96066e1f7 100644 --- a/packages/jupyterlab-lsp/src/features/highlights.ts +++ b/packages/jupyterlab-lsp/src/features/highlights.ts @@ -145,7 +145,7 @@ export class HighlightsCM extends CodeMirrorIntegration { return; } - if (!root_position) { + if (root_position == null) { this.console.warn('no root position available'); return; }