Skip to content

Commit

Permalink
Fixes to the tree expansion busy indicator
Browse files Browse the repository at this point in the history
Signed-off-by: Nigel Westbury <[email protected]>
  • Loading branch information
westbury committed Dec 8, 2020
1 parent 2d422af commit ec4804e
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions packages/core/src/browser/tree/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,26 +359,33 @@ export class TreeImpl implements Tree {
async markAsBusy(raw: TreeNode, ms: number, token: CancellationToken): Promise<void> {
const node = this.validateNode(raw);
if (node) {
await this.markAsBusy(node, ms, token);
await this.doMarkAsBusy(node, ms, token);
}
}
protected async doMarkAsBusy(node: Mutable<TreeNode>, ms: number, token: CancellationToken): Promise<void> {
try {
await timeout(ms, token);
this.doSetBusy(node, true);
token.onCancellationRequested(() => this.doSetBusy(node, false));
this.doSetBusy(node);
token.onCancellationRequested(() => this.doResetBusy(node));
} catch {
/* no-op */
}
}
protected doSetBusy(node: Mutable<TreeNode>, busy: boolean): void {
protected doSetBusy(node: Mutable<TreeNode>): void {
const oldBusy = node.busy || 0;
const newBusy = oldBusy + (busy ? 1 : oldBusy ? -1 : 0);
if (!!oldBusy === !!newBusy) {
return;
node.busy = oldBusy + 1;
if (oldBusy === 0) {
this.onDidChangeBusyEmitter.fire(node);
}
}
protected doResetBusy(node: Mutable<TreeNode>): void {
const oldBusy = node.busy || 0;
if (oldBusy > 0) {
node.busy = oldBusy - 1;
if (node.busy === 0) {
this.onDidChangeBusyEmitter.fire(node);
}
}
node.busy = newBusy;
this.onDidChangeBusyEmitter.fire(node);
}

}

0 comments on commit ec4804e

Please sign in to comment.