From 4e9d171a2328269da718b13ed39a20fdd150390c Mon Sep 17 00:00:00 2001 From: Qiming Zhao Date: Thu, 20 Jan 2022 21:29:43 +0800 Subject: [PATCH] Log document that can't perform semanticTokens --- history.md | 4 ++++ src/server/features/semanticTokens.ts | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/history.md b/history.md index de52c96..9bd595d 100644 --- a/history.md +++ b/history.md @@ -1,3 +1,7 @@ +# 1.9.8 + +- Log to output when document content exceed limit of semantic tokens. + # 1.9.7 - Change default of `javascript.autoClosingTags` and `typescript.autoClosingTags` to `true`. diff --git a/src/server/features/semanticTokens.ts b/src/server/features/semanticTokens.ts index 683f64f..2ad3e49 100644 --- a/src/server/features/semanticTokens.ts +++ b/src/server/features/semanticTokens.ts @@ -29,9 +29,14 @@ export default class TypeScriptDocumentSemanticTokensProvider implements Documen } } + private logIgnored(uri: string): void { + this.client.logger.warn(`${uri} content length exceed limit 100000`) + } + async provideDocumentSemanticTokens(document: TextDocument, token: CancellationToken): Promise { const file = this.client.toOpenedFilePath(document.uri) if (!file || document.getText().length > CONTENT_LENGTH_LIMIT) { + this.logIgnored(document.uri) return null } return this._provideSemanticTokens(document, { file, start: 0, length: document.getText().length }, token) @@ -40,6 +45,7 @@ export default class TypeScriptDocumentSemanticTokensProvider implements Documen async provideDocumentRangeSemanticTokens(document: TextDocument, range: Range, token: CancellationToken): Promise { const file = this.client.toOpenedFilePath(document.uri) if (!file || (document.offsetAt(range.end) - document.offsetAt(range.start) > CONTENT_LENGTH_LIMIT)) { + this.logIgnored(document.uri) return null }