From 27887574ef085cf3320f6729673e251aef46e55a Mon Sep 17 00:00:00 2001 From: chemzqm Date: Fri, 14 Jun 2019 19:28:19 +0800 Subject: [PATCH] fix error thrown on highlight --- src/server/features/documentHighlight.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/server/features/documentHighlight.ts b/src/server/features/documentHighlight.ts index 9e8572e..e6a0a44 100644 --- a/src/server/features/documentHighlight.ts +++ b/src/server/features/documentHighlight.ts @@ -24,16 +24,19 @@ export default class TypeScriptDocumentHighlightProvider implements DocumentHigh ...typeConverters.Position.toFileLocationRequestArgs(file, position), filesToSearch: [file] } - const response = await this.client.execute('documentHighlights', args, token) - if (response.type !== 'response' || !response.body) { + try { + const response = await this.client.execute('documentHighlights', args, token) + if (response.type !== 'response' || !response.body) { + return [] + } + return flatten( + response.body + .filter(highlight => highlight.file === file) + .map(convertDocumentHighlight)) + + } catch (_e) { return [] } - - return flatten( - response.body - .filter(highlight => highlight.file === file) - .map(convertDocumentHighlight)) - } }