From 0c579d7ac8bc5f94d3c9e4c1a1301950fdccea75 Mon Sep 17 00:00:00 2001 From: Pine Wu Date: Wed, 23 Jan 2019 15:10:12 -0800 Subject: [PATCH] Run safe for html selectionRange --- .../server/src/htmlServerMain.ts | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/extensions/html-language-features/server/src/htmlServerMain.ts b/extensions/html-language-features/server/src/htmlServerMain.ts index 2ccb26c3f60f0..bcc3feedf122a 100644 --- a/extensions/html-language-features/server/src/htmlServerMain.ts +++ b/extensions/html-language-features/server/src/htmlServerMain.ts @@ -480,17 +480,19 @@ connection.onFoldingRanges((params, token) => { }, null, `Error while computing folding regions for ${params.textDocument.uri}`, token); }); -connection.onRequest('$/textDocument/selectionRange', async (params) => { - const document = documents.get(params.textDocument.uri); - const position: Position = params.position; - - if (document) { - const htmlMode = languageModes.getMode('html'); - if (htmlMode && htmlMode.doSelection) { - return htmlMode.doSelection(document, position); +connection.onRequest('$/textDocument/selectionRange', async (params, token) => { + return runSafe(() => { + const document = documents.get(params.textDocument.uri); + const position: Position = params.position; + + if (document) { + const htmlMode = languageModes.getMode('html'); + if (htmlMode && htmlMode.doSelection) { + return htmlMode.doSelection(document, position); + } } - } - return Promise.resolve(null); + return Promise.resolve(null); + }, null, `Error while computing selection ranges for ${params.textDocument.uri}`, token); });