From 014ac55abe0a87aaffee9e05f65742d61cef3d7d Mon Sep 17 00:00:00 2001 From: Gordon Smith Date: Tue, 19 Dec 2023 12:30:24 +0000 Subject: [PATCH] fix: Workaround VSCode 1.85.x regression See https://github.com/microsoft/vscode/issues/201196 for more details Signed-off-by: Gordon Smith --- src/ecl/eclWatchTree.ts | 42 +++++++++++++++++------------------ src/ecl/tree.ts | 8 +++---- src/eclwatch/WUResult.tsx | 14 +++++++----- src/eclwatch/WUResultStore.ts | 5 ++++- 4 files changed, 38 insertions(+), 31 deletions(-) diff --git a/src/ecl/eclWatchTree.ts b/src/ecl/eclWatchTree.ts index 4dff8156..cbdf6c6a 100644 --- a/src/ecl/eclWatchTree.ts +++ b/src/ecl/eclWatchTree.ts @@ -57,8 +57,8 @@ export class ECLWatchTree extends Tree { this.refresh(); }); - vscode.commands.registerCommand("hpccPlatform.refresh", () => { - this.refresh(); + vscode.commands.registerCommand("hpccPlatform.refresh", (element?: Item) => { + this.refresh(element); }); vscode.commands.registerCommand("hpccPlatform.openResults", (wuNode: ECLWUNode) => { @@ -68,7 +68,7 @@ export class ECLWatchTree extends Tree { vscode.commands.registerCommand("hpccPlatform.browseMetrics", (wuNode: ECLWUNode) => { wuNode.browseMetrics(); }); - + vscode.commands.registerCommand("hpccPlatform.browseECLWatch", (wuNode: ECLWUNode) => { wuNode.browseECLWatch(); }); @@ -107,9 +107,9 @@ export class ECLWatchTree extends Tree { vscode.commands.executeCommand("setContext", "hpccPlatform.isAllWorkunits", !this._myWorkunits); } - refresh(): void { + refresh(element?: Item): void { this.updateMenu(); - super.refresh(); + super.refresh(element); } getRootChildren(): vscode.ProviderResult[]> { @@ -221,7 +221,6 @@ export const Circle = { const globe = new vscode.ThemeIcon("globe"); class ECLErrorNode extends Item { - private _wu: Workunit; constructor(tree: ECLWatchTree, private _error: Error) { super(tree); @@ -256,7 +255,11 @@ export class ECLResultNode extends Item { } getLabel(): string { - return `${this._result.Name}: ${this._result.Value}`; + return this._result.Name; + } + + getDescription(): string { + return this._result.Value ?? ""; } command(): vscode.Command | undefined { @@ -270,7 +273,6 @@ export class ECLResultNode extends Item { contextValue(): string { return "ECLResultNode"; } - } class ECLOutputsNode extends Item { @@ -310,26 +312,24 @@ export class ECLWUNode extends Item { this._wu = wu; this.url = `${wu.BaseUrl}/?Widget=WUDetailsWidget&Wuid=${wu.Wuid}`; if (!this._wu.isComplete()) { - let prevStateID; this._wu.watchUntilComplete(changes => { - if (prevStateID !== this._wu.StateID) { - prevStateID = this._wu.StateID; - this._tree._onDidChangeTreeData.fire(this); - } + tree.refresh(this); }); } } getLabel(): string { - let primary = this._wu.Wuid; + return this._wu.Jobname || this._wu.Wuid; + } + + getDescription(): string { const extras: string[] = []; - if (!this._wu.isComplete() || this._wu.isDeleted()) extras.push(this._wu.State); - if (!this._tree._myWorkunits && this._wu.Owner) extras.push(this._wu.Owner); if (this._wu.Jobname) { - primary = this._wu.Jobname; extras.push(this._wu.Wuid); } - return extras.length ? `${primary} (${extras.join(", ")})` : primary; + if (!this._tree._myWorkunits && this._wu.Owner) extras.push(this._wu.Owner); + if (!this._wu.isComplete() || this._wu.isDeleted()) extras.push(this._wu.State); + return extras.join(" "); } iconPath() { @@ -371,7 +371,7 @@ export class ECLWUNode extends Item { } browseMetrics() { - vscode.env.openExternal(vscode.Uri.parse(this.url+"/metrics")); + vscode.env.openExternal(vscode.Uri.parse(this.url + "/metrics")); } browseECLWatch() { @@ -381,7 +381,7 @@ export class ECLWUNode extends Item { openECL() { this._wu.fetchQuery().then((inf: WUInfo.Query) => { const ecl = inf.Text; - vscode.workspace.openTextDocument({content: ecl, language: "ecl"}).then(document => { + vscode.workspace.openTextDocument({ content: ecl, language: "ecl" }).then(document => { vscode.window.showTextDocument(document); }); }); @@ -397,7 +397,7 @@ export class ECLWUNode extends Item { } abort() { - this._wu.abort().then(() => this._tree._onDidChangeTreeData.fire(this)); + this._wu.abort().then(() => this._tree.refresh(this)); } delete() { diff --git a/src/ecl/tree.ts b/src/ecl/tree.ts index b3482505..ba423122 100644 --- a/src/ecl/tree.ts +++ b/src/ecl/tree.ts @@ -3,8 +3,8 @@ import { ExtensionContext, Event, EventEmitter, TreeItem, TreeDataProvider, Comm export class Tree implements TreeDataProvider { _ctx: ExtensionContext; - _onDidChangeTreeData: EventEmitter = new EventEmitter(); - readonly onDidChangeTreeData: Event = this._onDidChangeTreeData.event; + private _onDidChangeTreeData: EventEmitter = new EventEmitter(); + readonly onDidChangeTreeData: Event = this._onDidChangeTreeData.event; protected _treeView: TreeView; @@ -17,8 +17,8 @@ export class Tree implements TreeDataProvider { }); } - refresh(): void { - this._onDidChangeTreeData.fire(null); + refresh(element?: Item): void { + this._onDidChangeTreeData.fire(element); } getTreeItem(node: Item): TreeItem | Thenable { diff --git a/src/eclwatch/WUResult.tsx b/src/eclwatch/WUResult.tsx index 93d0536e..96325146 100644 --- a/src/eclwatch/WUResult.tsx +++ b/src/eclwatch/WUResult.tsx @@ -312,11 +312,15 @@ export class WUResultTable extends Common { this._prevHash = hash; this._result = this.calcResult(); if (this._result) { - this._result.fetchXMLSchema().then(schema => { - const store = new Store(this._result, schema, this.renderHtml()); - this._dgrid?.set("columns", store.columns()); - this._dgrid?.set("collection", store); - }); + this._result.fetchXMLSchema() + .then(schema => { + const store = new Store(this._result, schema, this.renderHtml()); + this._dgrid?.set("columns", store.columns()); + this._dgrid?.set("collection", store); + }).catch(e => { + this._prevHash = undefined; + }) + ; } } if (this._prevGrid !== this._dgrid) { diff --git a/src/eclwatch/WUResultStore.ts b/src/eclwatch/WUResultStore.ts index 9823a3c3..4c3221bf 100644 --- a/src/eclwatch/WUResultStore.ts +++ b/src/eclwatch/WUResultStore.ts @@ -186,7 +186,10 @@ export class Store { fetchRange(options): Promise { const retVal = new Deferred(); - this._request(options.start, options.end).then(response => retVal.resolve(response)); + this._request(options.start, options.end) + .then(response => retVal.resolve(response)) + .catch(e => retVal.reject(e)) + ; return new QueryResults(retVal.then(response => response.data), { totalLength: retVal.then(response => response.totalLength) });