diff --git a/package.json b/package.json index 16180c3e..5093b74a 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,9 @@ "onLanguage:sql" ], "extensionDependencies": [ - "halcyontechltd.code-for-ibmi" + "halcyontechltd.code-for-ibmi", + "RandomFractalsInc.vscode-data-table" + ], "main": "./dist/extension.js", "contributes": { diff --git a/src/notebooks/Controller.ts b/src/notebooks/Controller.ts index b2d59902..a86822d3 100644 --- a/src/notebooks/Controller.ts +++ b/src/notebooks/Controller.ts @@ -10,6 +10,10 @@ import { JobStatus } from '../connection/sqlJob'; import { ChartDetail, generateChart } from './logic/chart'; import { getStatementDetail } from './logic/statement'; +async function dataTableExtentionActivation() { + await vscode.extensions.getExtension('RandomFractalsInc.vscode-data-table')?.activate(); +} + export class IBMiController { readonly controllerId = `db2i-notebook-controller-id`; readonly notebookType = `db2i-notebook`; @@ -27,6 +31,9 @@ export class IBMiController { this.label ); + // activate vscode-data-table extention + dataTableExtentionActivation(); + this._controller.supportedLanguages = this.supportedLanguages; this._controller.supportsExecutionOrder = true; this._controller.executeHandler = this._execute.bind(this); @@ -60,7 +67,10 @@ export class IBMiController { const execution = this._controller.createNotebookCellExecution(cell); execution.executionOrder = ++this._executionOrder; execution.start(Date.now()); // Keep track of elapsed time to execute cell. - + if (cell.outputs.length > 0) { + execution.clearOutput(); + } + const selected = JobManager.getSelection(); execution.token.onCancellationRequested(() => { @@ -115,7 +125,7 @@ export class IBMiController { } if (fallbackToTable) { - items.push(vscode.NotebookCellOutputItem.text(mdTable(table, columns), `text/markdown`)); + items.push(vscode.NotebookCellOutputItem.text(JSON.stringify(table, null, 2), `application/json`)); } } else { items.push(vscode.NotebookCellOutputItem.stderr(`No rows returned from statement.`));