From c5228682a2a57026698471f5b32c17890ca0783f Mon Sep 17 00:00:00 2001 From: Jane Lewis Date: Thu, 13 Jun 2024 12:30:00 -0700 Subject: [PATCH] Introduce `ruff.printDebugInformation` command (#495) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Introduces a command to print debug information. It should look like this in the Output window: Screenshot 2024-06-10 at 12 21 07 PM ## Test Plan See https://github.com/astral-sh/ruff/pull/11831 for testing information. --- package.json | 5 +++++ src/extension.ts | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/package.json b/package.json index 8e9a72e..3b12ac9 100644 --- a/package.json +++ b/package.json @@ -365,6 +365,11 @@ "category": "Ruff", "command": "ruff.executeOrganizeImports" }, + { + "title": "Print debug information (native server only)", + "category": "Ruff", + "command": "ruff.debugInformation" + }, { "title": "Restart Server", "category": "Ruff", diff --git a/src/extension.ts b/src/extension.ts index 598a7e6..e8bcdc2 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -191,6 +191,8 @@ export async function activate(context: vscode.ExtensionContext): Promise }); }), registerCommand(`${serverId}.executeFormat`, async () => { + // let configuration = getConfiguration(serverId) as ISettings; + if (!lsClient) { return; } @@ -240,6 +242,20 @@ export async function activate(context: vscode.ExtensionContext): Promise ); }); }), + registerCommand(`${serverId}.debugInformation`, async () => { + let configuration = getConfiguration(serverId) as unknown as ISettings; + if (!lsClient || !configuration.nativeServer) { + return; + } + + const params = { + command: `${serverId}.printDebugInformation`, + }; + + await lsClient.sendRequest(ExecuteCommandRequest.type, params).then(undefined, async () => { + await vscode.window.showErrorMessage("Failed to print debug information."); + }); + }), registerLanguageStatusItem(serverId, serverName, `${serverId}.showLogs`), );