Browse Source

Add ability to suppress LSP error messages (#823)

David Kincaid 5 months ago
parent
commit
e38db288b7
1 changed files with 17 additions and 0 deletions
  1. 17 0
      src/lsp/GDScriptLanguageClient.ts

+ 17 - 0
src/lsp/GDScriptLanguageClient.ts

@@ -3,6 +3,7 @@ import * as path from "node:path";
 import * as vscode from "vscode";
 import {
 	LanguageClient,
+	MessageSignature,
 	type LanguageClientOptions,
 	type NotificationMessage,
 	type RequestMessage,
@@ -139,6 +140,22 @@ export default class GDScriptLanguageClient extends LanguageClient {
 		}
 	}
 
+	handleFailedRequest<T>(
+		type: MessageSignature,
+		token: vscode.CancellationToken | undefined,
+		error: any,
+		defaultValue: T,
+		showNotification?: boolean,
+	): T {
+		if (type.method === "textDocument/documentSymbol") {
+			if (error.message.includes("selectionRange must be contained in fullRange")) {
+				log.warn(`Request failed for method "${type.method}", suppressing notification - see issue #820`);
+				return super.handleFailedRequest(type, token, error, defaultValue, false);
+			}
+		}
+		return super.handleFailedRequest(type, token, error, defaultValue, showNotification);
+	}
+
 	private request_filter(message: RequestMessage) {
 		if (this.rejected) {
 			if (message.method === "shutdown") {