Skip to content

Commit 100b280

Browse files
Merge pull request #659 from KxSystems/fix-merge-main
Fix merge main
2 parents 34288a1 + dac7105 commit 100b280

File tree

5 files changed

+82
-55
lines changed

5 files changed

+82
-55
lines changed

.vscode/launch.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@
99
"name": "Run Extension",
1010
"type": "extensionHost",
1111
"request": "launch",
12-
"args": [
13-
"--profile-temp",
14-
"--extensionDevelopmentPath=${workspaceFolder}"
15-
],
12+
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
1613
"outFiles": ["${workspaceFolder}/out/extension.js*"],
1714
"preLaunchTask": "npm: watch"
1815
},
1916
{
20-
"name": "Run Extension Inline",
17+
"name": "Run Extension Plain",
2118
"type": "extensionHost",
2219
"request": "launch",
23-
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
20+
"args": [
21+
"--profile-temp",
22+
"--extensionDevelopmentPath=${workspaceFolder}"
23+
],
2424
"outFiles": ["${workspaceFolder}/out/extension.js*"],
2525
"preLaunchTask": "npm: watch"
2626
},

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
All notable changes to the **kdb VS Code extension** are documented in this file.
44

5+
# v1.13.1
6+
7+
### Fixes
8+
9+
- Fixed issue with corrupted settings for VSCode
10+
- Fixed OpenSSL message severity: debug messages were incorrectly logged as errors
11+
512
# v1.13.0
613

714
### Enhancements

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils/core.ts

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -244,16 +244,20 @@ export async function getWorkspaceFolder(
244244
return undefined;
245245
}
246246

247-
export function getServers(): Server | undefined {
247+
export function getServers(): Server {
248248
const servers = workspace.getConfiguration().get<Server>("kdb.servers");
249249

250+
if (!servers) {
251+
updateServers({});
252+
}
253+
250254
return servers
251255
? Object.fromEntries(
252256
Object.entries(servers).sort(([, a], [, b]) =>
253257
a.serverAlias.localeCompare(b.serverAlias),
254258
),
255259
)
256-
: servers;
260+
: {};
257261
}
258262

259263
// TODO: Remove this on 1.9.0 release
@@ -328,28 +332,36 @@ export function setOutputWordWrapper(): void {
328332
}
329333
}
330334

331-
export function getInsights(): Insights | undefined {
335+
export function getInsights(): Insights {
332336
const configuration = workspace.getConfiguration();
333337
const insights = configuration.get<Insights>(
334338
"kdb.insightsEnterpriseConnections",
335339
);
336340

337-
const insightsList: Insights | undefined =
338-
insights && Object.keys(insights).length > 0
339-
? insights
340-
: configuration.get("kdb.insights");
341-
342-
if (!insightsList || Object.keys(insightsList).length === 0) {
343-
return undefined;
344-
}
345-
346-
return insightsList
347-
? Object.fromEntries(
341+
if (insights && Object.keys(insights).length > 0) {
342+
return Object.fromEntries(
343+
Object.entries(insights).sort(([, a], [, b]) =>
344+
a.alias.localeCompare(b.alias),
345+
),
346+
);
347+
} else {
348+
const insightsList = configuration.get<Insights>("kdb.insights");
349+
if (insightsList && Object.keys(insightsList).length > 0) {
350+
updateInsights(insightsList);
351+
configuration.update(
352+
"kdb.insights",
353+
undefined,
354+
ConfigurationTarget.Global,
355+
);
356+
return Object.fromEntries(
348357
Object.entries(insightsList).sort(([, a], [, b]) =>
349358
a.alias.localeCompare(b.alias),
350359
),
351-
)
352-
: insightsList;
360+
);
361+
}
362+
updateInsights({});
363+
return {};
364+
}
353365
}
354366

355367
export async function updateServers(servers: Server): Promise<void> {

test/suite/utils/core.test.ts

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ describe("core", () => {
209209
beforeEach(() => {
210210
appendLineSpy = sinon.spy(
211211
vscode.window.createOutputChannel("testChannel"),
212-
"appendLine",
212+
"appendLine"
213213
);
214214
showErrorMessageSpy = sinon.spy(vscode.window, "showErrorMessage");
215215
});
@@ -299,11 +299,16 @@ describe("core", () => {
299299
});
300300

301301
describe("getServers", () => {
302-
let workspaceStub, _getConfigurationStub, getStub: sinon.SinonStub;
302+
let workspaceStub,
303+
_getConfigurationStub,
304+
getStub,
305+
updateServersStub: sinon.SinonStub;
303306

304307
beforeEach(() => {
305308
getStub = sinon.stub();
306-
_getConfigurationStub = sinon.stub().returns({ get: getStub });
309+
_getConfigurationStub = sinon
310+
.stub()
311+
.returns({ get: getStub, update: sinon.stub() });
307312
workspaceStub = sinon.stub(vscode.workspace, "getConfiguration").returns({
308313
get: getStub,
309314
has: function (_section: string): boolean {
@@ -329,22 +334,24 @@ describe("core", () => {
329334
_section: string,
330335
_value: any,
331336
_configurationTarget?: vscode.ConfigurationTarget | boolean | null,
332-
_overrideInLanguage?: boolean,
337+
_overrideInLanguage?: boolean
333338
): Thenable<void> {
334339
throw new Error("Function not implemented.");
335340
},
336341
});
342+
updateServersStub = sinon.stub(coreUtils, "updateServers").resolves();
337343
});
338344

339345
afterEach(() => {
340346
sinon.restore();
341347
});
342348

343-
it("should return undefined when no servers are configured", () => {
344-
getStub.returns(undefined);
349+
it("should return an empty object when no servers are configured", () => {
350+
getStub.returns({});
345351
const result = coreUtils.getServers();
346352

347-
assert.strictEqual(result, undefined);
353+
assert.ok(typeof result === "object");
354+
assert.strictEqual(Object.keys(result).length, 0);
348355
assert.ok(getStub.calledWith("kdb.servers"));
349356
});
350357

@@ -510,7 +517,7 @@ describe("core", () => {
510517

511518
coreUtils.getServers();
512519

513-
assert.ok(workspaceStub.calledOnce);
520+
assert.ok(workspaceStub.calledTwice);
514521
assert.ok(workspaceStub.calledWith());
515522
});
516523

@@ -525,11 +532,16 @@ describe("core", () => {
525532
});
526533

527534
describe("getInsights", () => {
528-
let workspaceStub, _getConfigurationStub, getStub: sinon.SinonStub;
535+
let workspaceStub,
536+
_getConfigurationStub,
537+
getStub,
538+
updateInsightsStub: sinon.SinonStub;
529539

530540
beforeEach(() => {
531541
getStub = sinon.stub();
532-
_getConfigurationStub = sinon.stub().returns({ get: getStub });
542+
_getConfigurationStub = sinon
543+
.stub()
544+
.returns({ get: getStub, update: sinon.stub() });
533545
workspaceStub = sinon.stub(vscode.workspace, "getConfiguration").returns({
534546
get: getStub,
535547
has: function (_section: string): boolean {
@@ -551,15 +563,9 @@ describe("core", () => {
551563
| undefined {
552564
throw new Error("Function not implemented.");
553565
},
554-
update: function (
555-
_section: string,
556-
_value: any,
557-
_configurationTarget?: vscode.ConfigurationTarget | boolean | null,
558-
_overrideInLanguage?: boolean,
559-
): Thenable<void> {
560-
throw new Error("Function not implemented.");
561-
},
566+
update: sinon.stub(),
562567
});
568+
updateInsightsStub = sinon.stub(coreUtils, "updateInsights").resolves();
563569
});
564570

565571
afterEach(() => {
@@ -572,7 +578,8 @@ describe("core", () => {
572578

573579
const result = coreUtils.getInsights();
574580

575-
assert.strictEqual(result, undefined);
581+
assert.ok(typeof result === "object");
582+
assert.strictEqual(Object.keys(result).length, 0);
576583
assert.ok(getStub.calledWith("kdb.insightsEnterpriseConnections"));
577584
assert.ok(getStub.calledWith("kdb.insights"));
578585
});
@@ -620,7 +627,7 @@ describe("core", () => {
620627

621628
assert.strictEqual(
622629
result[insightKeys[0]].server,
623-
"https://alpha.insights.com",
630+
"https://alpha.insights.com"
624631
);
625632
assert.strictEqual(result[insightKeys[0]].auth, false);
626633
assert.strictEqual(result[insightKeys[1]].realm, "beta-realm");
@@ -692,7 +699,8 @@ describe("core", () => {
692699

693700
const result = coreUtils.getInsights();
694701

695-
assert.strictEqual(result, undefined);
702+
assert.ok(typeof result === "object");
703+
assert.strictEqual(Object.keys(result).length, 0);
696704
assert.ok(getStub.calledWith("kdb.insightsEnterpriseConnections"));
697705
assert.ok(getStub.calledWith("kdb.insights"));
698706
});
@@ -720,7 +728,7 @@ describe("core", () => {
720728
assert.strictEqual(result[insightKeys[0]].alias, "Only Insight");
721729
assert.strictEqual(
722730
result[insightKeys[0]].server,
723-
"https://only.insights.com",
731+
"https://only.insights.com"
724732
);
725733
});
726734

@@ -827,7 +835,7 @@ describe("core", () => {
827835

828836
coreUtils.getInsights();
829837

830-
assert.ok(workspaceStub.calledOnce);
838+
assert.ok(workspaceStub.calledTwice);
831839
assert.ok(workspaceStub.calledWith());
832840
});
833841

@@ -868,10 +876,10 @@ describe("core", () => {
868876
assert.strictEqual(insightKeys.length, 2);
869877

870878
const basicInsight = Object.values(result).find(
871-
(i) => i.alias === "Basic Insight",
879+
(i) => i.alias === "Basic Insight"
872880
);
873881
const fullInsight = Object.values(result).find(
874-
(i) => i.alias === "Full Insight",
882+
(i) => i.alias === "Full Insight"
875883
);
876884

877885
assert.ok(basicInsight);
@@ -993,9 +1001,9 @@ describe("core", () => {
9931001
updateConfigurationStub.calledWith(
9941002
"kdb.neverShowQInstallAgain",
9951003
true,
996-
vscode.ConfigurationTarget.Global,
1004+
vscode.ConfigurationTarget.Global
9971005
),
998-
true,
1006+
true
9991007
);
10001008
});
10011009
});

0 commit comments

Comments
 (0)