Skip to content

Commit d15a2d2

Browse files
authored
Merge pull request #700 from KxSystems/ee-repl
Run on REPL by default
2 parents b1a4137 + 24b97a9 commit d15a2d2

File tree

8 files changed

+29
-246
lines changed

8 files changed

+29
-246
lines changed

src/commands/workspaceCommand.ts

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import { ConnectionManagementService } from "../services/connectionManagerServic
3939
import { InsightsNode, KdbNode, LabelNode } from "../services/kdbTreeProvider";
4040
import { updateCellMetadata } from "../services/notebookProviders";
4141
import { getBasename, offerConnectAction } from "../utils/core";
42-
import { importOldDsFiles, oldFilesExists } from "../utils/dataSource";
42+
import { importOldDsFiles } from "../utils/dataSource";
4343
import {
4444
Cancellable,
4545
MessageKind,
@@ -221,12 +221,7 @@ export async function pickConnection(uri: Uri) {
221221
/* c8 ignore start */
222222
const server = getServerForUri(uri);
223223
const servers = getServers();
224-
225-
const items = ["(none)"];
226-
if (isQ(uri) || isNotebook(uri) || isPython(uri) || isSql(uri)) {
227-
items.push(ext.REPL);
228-
}
229-
items.push(...servers);
224+
const items = ["(none)", ...servers];
230225

231226
let picked = await window.showQuickPick(items, {
232227
title: `Choose Connection (${getBasename(uri)})`,
@@ -449,14 +444,6 @@ function isSql(uri: Uri | undefined) {
449444
return uri && uri.path.endsWith(".sql");
450445
}
451446

452-
function isQ(uri: Uri | undefined) {
453-
return uri && uri.path.endsWith(".q");
454-
}
455-
456-
function isNotebook(uri: Uri | undefined) {
457-
return uri && uri.path.endsWith(".kxnb");
458-
}
459-
460447
function isPython(uri: Uri | undefined) {
461448
return uri && uri.path.endsWith(".py");
462449
}
@@ -532,7 +519,12 @@ export async function runActiveEditor(type?: ExecutionTypes) {
532519
/* c8 ignore start */
533520
if (ext.activeTextEditor) {
534521
const uri = ext.activeTextEditor.document.uri;
535-
if (getServerForUri(uri) === ext.REPL) {
522+
let server = getServerForUri(uri);
523+
if (server === ext.REPL) {
524+
server = undefined;
525+
await setServerForUri(uri, undefined);
526+
}
527+
if (server === undefined) {
536528
runOnRepl(ext.activeTextEditor, type);
537529
return;
538530
}
@@ -693,10 +685,6 @@ export function connectWorkspaceCommands() {
693685
activeEditorChanged(window.activeTextEditor);
694686
}
695687

696-
export function checkOldDatasourceFiles() {
697-
ext.oldDSformatExists = oldFilesExists();
698-
}
699-
700688
export async function importOldDSFiles() {
701689
/* c8 ignore start */
702690
if (ext.oldDSformatExists) {

src/extension.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ import {
4949
import { installKdbX, showWelcome } from "./commands/setupCommand";
5050
import {
5151
ConnectionLensProvider,
52-
checkOldDatasourceFiles,
5352
connectWorkspaceCommands,
5453
importOldDSFiles,
5554
pickConnection,
@@ -108,7 +107,6 @@ import {
108107
import {
109108
checkLocalInstall,
110109
checkOpenSslInstalled,
111-
fixUnnamedAlias,
112110
getInsights,
113111
getServers,
114112
hasWorkspaceOrShowOption,
@@ -156,8 +154,6 @@ export async function activate(context: vscode.ExtensionContext) {
156154
"datasource",
157155
);
158156

159-
fixUnnamedAlias();
160-
161157
vscode.commands.executeCommand("setContext", "kdb.QHOME", env.QHOME);
162158

163159
vscode.window.registerTreeDataProvider("kdb-servers", ext.serverProvider);
@@ -220,8 +216,6 @@ export async function activate(context: vscode.ExtensionContext) {
220216
}),
221217
);
222218

223-
checkOldDatasourceFiles();
224-
225219
const lastResult: QueryResult | undefined = undefined;
226220
const resultSchema = "vscode-kdb-q";
227221
const resultProvider = new (class
@@ -266,9 +260,6 @@ export async function activate(context: vscode.ExtensionContext) {
266260
),
267261
);
268262

269-
connectWorkspaceCommands();
270-
await connectBuildTools();
271-
272263
//q language server
273264
const serverModule = path.join(context.extensionPath, "out", "server.js");
274265
const debugOptions = { execArgv: ["--nolazy", "--inspect=6009"] };
@@ -313,8 +304,8 @@ export async function activate(context: vscode.ExtensionContext) {
313304
);
314305

315306
await client.start();
316-
317307
connectClientCommands(context, client);
308+
await connectBuildTools();
318309

319310
const yamlExtension = vscode.extensions.getExtension("redhat.vscode-yaml");
320311
if (yamlExtension) {
@@ -1014,6 +1005,7 @@ function registerAllExtensionCommands(): void {
10141005
vscode.commands.registerCommand(command.command, command.callback),
10151006
);
10161007
});
1008+
connectWorkspaceCommands();
10171009
}
10181010

10191011
export async function deactivate(): Promise<void> {

src/q/list_mem.q

Lines changed: 0 additions & 82 deletions
This file was deleted.

src/services/notebookController.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ import {
2323
runDataSource,
2424
} from "../commands/dataSourceCommand";
2525
import { executeQuery } from "../commands/serverCommand";
26-
import { findConnection, getServerForUri } from "../commands/workspaceCommand";
26+
import {
27+
findConnection,
28+
getServerForUri,
29+
setServerForUri,
30+
} from "../commands/workspaceCommand";
2731
import { ext } from "../extensionVariables";
2832
import { CellKind } from "../models/notebook";
2933
import { getBasename } from "../utils/core";
@@ -107,7 +111,12 @@ export class KxNotebookController {
107111
notebook: vscode.NotebookDocument,
108112
controller: vscode.NotebookController,
109113
): Promise<void> {
110-
if (getServerForUri(notebook.uri) === ext.REPL) {
114+
let server = getServerForUri(notebook.uri);
115+
if (server === ext.REPL) {
116+
server = undefined;
117+
await setServerForUri(notebook.uri, undefined);
118+
}
119+
if (server === undefined) {
111120
return this.executeRepl(cells, notebook, controller);
112121
}
113122

src/utils/core.ts

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -272,47 +272,6 @@ export function getServers(): Server {
272272
: {};
273273
}
274274

275-
// TODO: Remove this on 1.9.0 release
276-
export function fixUnnamedAlias(): void {
277-
/* c8 ignore start */
278-
const servers = getServers();
279-
const insights = getInsights();
280-
let counter = 1;
281-
282-
if (servers) {
283-
const updatedServers: Server = {};
284-
for (const key in servers) {
285-
if (Object.prototype.hasOwnProperty.call(servers, key)) {
286-
const server = servers[key];
287-
if (server.serverAlias === "") {
288-
server.serverAlias = `unnamedServer-${counter}`;
289-
counter++;
290-
}
291-
updatedServers[server.serverAlias] = server;
292-
}
293-
}
294-
updateServers(updatedServers);
295-
ext.serverProvider.refresh(servers);
296-
}
297-
298-
if (insights) {
299-
const updatedInsights: Insights = {};
300-
for (const key in insights) {
301-
if (Object.prototype.hasOwnProperty.call(insights, key)) {
302-
const insight = insights[key];
303-
if (insight.alias === "") {
304-
insight.alias = `unnamedServer-${counter}`;
305-
counter++;
306-
}
307-
updatedInsights[insight.alias] = insight;
308-
}
309-
}
310-
updateInsights(updatedInsights);
311-
ext.serverProvider.refreshInsights(insights);
312-
}
313-
/* c8 ignore stop */
314-
}
315-
316275
export function getAutoFocusOutputOnEntrySetting(): boolean {
317276
return workspace
318277
.getConfiguration("kdb")

test/suite/commands/workspaceCommand.test.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,6 @@ describe("workspaceCommand", () => {
240240
afterEach(() => {
241241
oldFilesExistsStub.restore();
242242
});
243-
244-
it("should check for old datasource files", async () => {
245-
oldFilesExistsStub.returns(true);
246-
await workspaceCommand.checkOldDatasourceFiles();
247-
sinon.assert.calledOnce(oldFilesExistsStub);
248-
});
249243
});
250244

251245
describe("importOldDSFiles", () => {

0 commit comments

Comments
 (0)