Skip to content

Commit

Permalink
Run safe for html selectionRange
Browse files Browse the repository at this point in the history
  • Loading branch information
octref committed Jan 23, 2019
1 parent 4d503b2 commit 0c579d7
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions extensions/html-language-features/server/src/htmlServerMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});


Expand Down

0 comments on commit 0c579d7

Please sign in to comment.