Run safe for html selectionRange

This commit is contained in:
Pine Wu
2019-01-23 15:10:12 -08:00
parent 4d503b21cd
commit 0c579d7ac8

View File

@@ -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;
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);
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);
});