From d1da54afe805aad7bcd7902888749af0acc9d4de Mon Sep 17 00:00:00 2001 From: Philip Carneiro Date: Thu, 6 Jun 2024 16:14:19 +0100 Subject: [PATCH 1/2] fix local conn issues --- src/classes/localConnection.ts | 5 +++-- src/extension.ts | 6 ++++-- src/services/connectionManagerService.ts | 13 +++---------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/classes/localConnection.ts b/src/classes/localConnection.ts index 4fb9e608..e56c5268 100644 --- a/src/classes/localConnection.ts +++ b/src/classes/localConnection.ts @@ -12,7 +12,7 @@ */ import * as nodeq from "node-q"; -import { window } from "vscode"; +import { commands, window } from "vscode"; import { ext } from "../extensionVariables"; import { delay } from "../utils/core"; import { convertStringToArray, handleQueryResults } from "../utils/execution"; @@ -85,10 +85,11 @@ export class LocalConnection { return; } conn.addListener("close", () => { + commands.executeCommand("kdb.disconnect", this.connLabel); ext.outputChannel.appendLine( `Connection stopped from ${this.options.host}:${this.options.port}`, ); - this.connected = false; + ext.outputChannel.show(); }); if (this.connection && this.connected) { diff --git a/src/extension.ts b/src/extension.ts index 29c92ef8..acd4501c 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -214,8 +214,10 @@ export async function activate(context: ExtensionContext) { ), commands.registerCommand( "kdb.disconnect", - async (viewItem: InsightsNode | KdbNode) => { - await disconnect(viewItem.label); + async (viewItem: InsightsNode | KdbNode | string) => { + const connLabel = + typeof viewItem === "string" ? viewItem : viewItem.label; + await disconnect(connLabel); }, ), commands.registerCommand("kdb.addConnection", async () => { diff --git a/src/services/connectionManagerService.ts b/src/services/connectionManagerService.ts index 0d326b9f..c9182884 100644 --- a/src/services/connectionManagerService.ts +++ b/src/services/connectionManagerService.ts @@ -143,19 +143,12 @@ export class ConnectionManagementService { public disconnect(connLabel: string): void { const connection = this.retrieveConnectedConnection(connLabel); const connectionNode = this.retrieveConnection(connLabel); - if (!connection) { + if (!connection || !connectionNode) { return; } - const isLocal = connection instanceof LocalConnection; /* istanbul ignore next */ - if (isLocal && connectionNode) { - connection.getConnection()?.close(() => { - this.disconnectBehaviour(connection); - }); - } else { - connection.disconnect(); - this.disconnectBehaviour(connection); - } + connection.disconnect(); + this.disconnectBehaviour(connection); } public async removeConnection( From ccc44ea8da127e265cbcf4ccb2fba799e38b6bb3 Mon Sep 17 00:00:00 2001 From: Philip Carneiro Date: Fri, 7 Jun 2024 08:50:50 +0100 Subject: [PATCH 2/2] show console output if results tab are not visible --- src/utils/executionConsole.ts | 11 +++++------ test/runTest.ts | 6 +++++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/utils/executionConsole.ts b/src/utils/executionConsole.ts index 20b66986..a6bc6d0f 100644 --- a/src/utils/executionConsole.ts +++ b/src/utils/executionConsole.ts @@ -88,13 +88,12 @@ export class ExecutionConsole { const hideDetails = ext.hideDetailedConsoleQueryOutput; output = this.checkOutput(output, query); let dataSourceRes: string[] = []; - if (type === undefined) { - this._console.show(true); - } else { - if (Array.isArray(output)) { - dataSourceRes = convertRowsToConsole(output); - } + this._console.show(true); + + if (Array.isArray(output)) { + dataSourceRes = convertRowsToConsole(output); } + if (!checkIfIsDatasource(type)) { addQueryHistory( query, diff --git a/test/runTest.ts b/test/runTest.ts index 90256bef..774e2184 100644 --- a/test/runTest.ts +++ b/test/runTest.ts @@ -34,7 +34,11 @@ async function main() { process.env["GENERATE_COVERAGE"] = "1"; } - await runTests({ extensionDevelopmentPath, extensionTestsPath }); + await runTests({ + extensionDevelopmentPath, + extensionTestsPath, + version: "1.89.1", + }); } catch (err) { console.log(err); console.error("Failed to run tests.");