Skip to content

Commit

Permalink
fix: Workaround VSCode 1.85.x regression
Browse files Browse the repository at this point in the history
See microsoft/vscode#201196 for more details

Signed-off-by: Gordon Smith <GordonJSmith@gmail.com>
  • Loading branch information
GordonSmith committed Dec 19, 2023
1 parent 470f6f4 commit 014ac55
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 31 deletions.
42 changes: 21 additions & 21 deletions src/ecl/eclWatchTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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();
});
Expand Down Expand Up @@ -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<Item<ECLWatchTree>[]> {
Expand Down Expand Up @@ -221,7 +221,6 @@ export const Circle = {
const globe = new vscode.ThemeIcon("globe");

class ECLErrorNode extends Item<ECLWatchTree> {
private _wu: Workunit;

constructor(tree: ECLWatchTree, private _error: Error) {
super(tree);
Expand Down Expand Up @@ -256,7 +255,11 @@ export class ECLResultNode extends Item<ECLWatchTree> {
}

getLabel(): string {
return `${this._result.Name}: ${this._result.Value}`;
return this._result.Name;
}

getDescription(): string {
return this._result.Value ?? "";
}

command(): vscode.Command | undefined {
Expand All @@ -270,7 +273,6 @@ export class ECLResultNode extends Item<ECLWatchTree> {
contextValue(): string {
return "ECLResultNode";
}

}

class ECLOutputsNode extends Item<ECLWatchTree> {
Expand Down Expand Up @@ -310,26 +312,24 @@ export class ECLWUNode extends Item<ECLWatchTree> {
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() {
Expand Down Expand Up @@ -371,7 +371,7 @@ export class ECLWUNode extends Item<ECLWatchTree> {
}

browseMetrics() {
vscode.env.openExternal(vscode.Uri.parse(this.url+"/metrics"));
vscode.env.openExternal(vscode.Uri.parse(this.url + "/metrics"));
}

browseECLWatch() {
Expand All @@ -381,7 +381,7 @@ export class ECLWUNode extends Item<ECLWatchTree> {
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);
});
});
Expand All @@ -397,7 +397,7 @@ export class ECLWUNode extends Item<ECLWatchTree> {
}

abort() {
this._wu.abort().then(() => this._tree._onDidChangeTreeData.fire(this));
this._wu.abort().then(() => this._tree.refresh(this));
}

delete() {
Expand Down
8 changes: 4 additions & 4 deletions src/ecl/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { ExtensionContext, Event, EventEmitter, TreeItem, TreeDataProvider, Comm
export class Tree implements TreeDataProvider<Item> {
_ctx: ExtensionContext;

_onDidChangeTreeData: EventEmitter<Item | null> = new EventEmitter<Item | null>();
readonly onDidChangeTreeData: Event<Item | null> = this._onDidChangeTreeData.event;
private _onDidChangeTreeData: EventEmitter<Item | undefined> = new EventEmitter<Item | undefined>();
readonly onDidChangeTreeData: Event<Item | undefined> = this._onDidChangeTreeData.event;

protected _treeView: TreeView<Item>;

Expand All @@ -17,8 +17,8 @@ export class Tree implements TreeDataProvider<Item> {
});
}

refresh(): void {
this._onDidChangeTreeData.fire(null);
refresh(element?: Item): void {
this._onDidChangeTreeData.fire(element);
}

getTreeItem(node: Item): TreeItem | Thenable<TreeItem> {
Expand Down
14 changes: 9 additions & 5 deletions src/eclwatch/WUResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 4 additions & 1 deletion src/eclwatch/WUResultStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,10 @@ export class Store {

fetchRange(options): Promise<any[]> {
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)
});
Expand Down

0 comments on commit 014ac55

Please sign in to comment.