From 47cd21a7e43afdf44850835fb291705255ef041b Mon Sep 17 00:00:00 2001 From: AMJ <69196954+ThisAMJ@users.noreply.github.com> Date: Sun, 13 Oct 2024 13:37:33 +1100 Subject: [PATCH] fix: error on launch --- client/src/extension.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/src/extension.ts b/client/src/extension.ts index 36c9ec2..38ec335 100644 --- a/client/src/extension.ts +++ b/client/src/extension.ts @@ -80,7 +80,7 @@ export function activate(context: vscode.ExtensionContext) { if (configuration.get("showActiveToolsDisplay")) { // Draw the active tools display when the client is ready to have it pop up - client.onReady().then(() => drawActiveToolsDisplay(vscode.window.activeTextEditor!.selection.active, vscode.window.activeTextEditor!.document)); + client.onReady().then(() => drawActiveToolsDisplay(vscode.window.activeTextEditor?.selection.active, vscode.window.activeTextEditor?.document)); } // Start the client. This will also launch the server @@ -300,6 +300,7 @@ function parseActiveTools(str: string): ActiveTool[] { } async function drawActiveToolsDisplay(cursorPos: vscode.Position, document: vscode.TextDocument) { + if (!cursorPos || !document) return; const toolsStr: string = await client.sendRequest("p2tas/activeTools", [document.uri, cursorPos.line]); const tools = parseActiveTools(toolsStr);