Skip to content

Commit

Permalink
Merge pull request #157 from KxSystems/KXI-31194
Browse files Browse the repository at this point in the history
KXI-31194 - Horizontal scrolling missing in q console output
  • Loading branch information
Philip-Carneiro-KX authored Oct 20, 2023
2 parents cc61c35 + c35b507 commit 06d22e1
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/commands/serverCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ export async function removeInsightsConnection(
export async function connect(viewItem: KdbNode): Promise<void> {
commands.executeCommand("kdb-results.focus");
await commands.executeCommand("setContext", "kdb.insightsConnected", false);
const queryConsole = ExecutionConsole.start();
// handle cleaning up existing connection
if (
ext.connectionNode !== undefined &&
Expand Down
29 changes: 25 additions & 4 deletions src/utils/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,34 @@ export function getServers(): Server | undefined {
return workspace.getConfiguration().get("kdb.servers");
}

export function setOutputWordWrapper(): void {
let existWrap = false;
const logConfig = workspace.getConfiguration("[Log]");
if (logConfig) {
const wordWrap = logConfig["editor.wordWrap"];
if (wordWrap) {
existWrap = true;
}
}
if (!existWrap) {
workspace
.getConfiguration()
.update(
"[Log]",
{ "editor.wordWrap": "off" },
ConfigurationTarget.Global
);
}
}

export function getInsights(): Insights | undefined {
const configuration = workspace.getConfiguration();
const insights =
configuration.get<Insights>("kdb.insightsEnterpriseConnections");
const insights = configuration.get<Insights>(
"kdb.insightsEnterpriseConnections"
);

return insights && Object.keys(insights).length > 0
? insights
return insights && Object.keys(insights).length > 0
? insights
: configuration.get("kdb.insights");
}

Expand Down
2 changes: 2 additions & 0 deletions src/utils/executionConsole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { ext } from "../extensionVariables";
import { QueryHistory } from "../models/queryHistory";
import { ServerType } from "../models/server";
import { KdbNode } from "../services/kdbTreeProvider";
import { setOutputWordWrapper } from "./core";
import { convertRowsToConsole } from "./queryUtils";

export class ExecutionConsole {
Expand All @@ -27,6 +28,7 @@ export class ExecutionConsole {
}

public static start(): ExecutionConsole {
setOutputWordWrapper();
if (!ExecutionConsole.current) {
const _console = window.createOutputChannel("q Console Output");
ExecutionConsole.current = new ExecutionConsole(_console);
Expand Down
28 changes: 28 additions & 0 deletions test/suite/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { QueryResultType } from "../../src/models/queryResult";
import { ServerType } from "../../src/models/server";
import { InsightsNode, KdbNode } from "../../src/services/kdbTreeProvider";
import { QueryHistoryProvider } from "../../src/services/queryHistoryProvider";
import * as coreUtils from "../../src/utils/core";
import * as dataSourceUtils from "../../src/utils/dataSource";
import * as executionUtils from "../../src/utils/execution";
import * as executionConsoleUtils from "../../src/utils/executionConsole";
Expand Down Expand Up @@ -55,6 +56,33 @@ describe("Utils", () => {
windowMock.restore();
});

describe("core", () => {
describe("setOutputWordWrapper", () => {
let getConfigurationStub: sinon.SinonStub;
beforeEach(() => {
getConfigurationStub = sinon.stub(vscode.workspace, "getConfiguration");
});

afterEach(() => {
getConfigurationStub.restore();
});
it("should create wordwrapper if doesn't exist", () => {
getConfigurationStub.returns({
get: sinon.stub().returns({ "[Log]": { "editor.wordWrap": "off" } }),
update: sinon.stub(),
});
coreUtils.setOutputWordWrapper();
sinon.assert.calledTwice(getConfigurationStub);
});

it("should let wordwrapper if it exist", () => {
getConfigurationStub.returns({ "editor.wordWrap": "on" });
coreUtils.setOutputWordWrapper();
sinon.assert.calledOnce(getConfigurationStub);
});
});
});

describe("dataSource", () => {
// need check how to mock ext variables and populate it with values
// it("createKdbDataSourcesFolder", () => {
Expand Down

0 comments on commit 06d22e1

Please sign in to comment.