Browse Source

Fixes #2185, #2180 pr node refresh causes issues

I've disabled the refresh to show the spinner icon on the root node to avoid this issue until I can dig into this more. It looks like this is a bug in the VS Code tree view.
main
Eric Amodio 2 years ago
parent
commit
2760a2f4c0
4 changed files with 82 additions and 82 deletions
  1. +2
    -0
      CHANGELOG.md
  2. +28
    -29
      src/views/nodes/branchNode.ts
  3. +26
    -26
      src/views/nodes/commitNode.ts
  4. +26
    -27
      src/views/nodes/worktreeNode.ts

+ 2
- 0
CHANGELOG.md View File

@ -8,6 +8,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed
- Fixes [#2185](https://github.com/gitkraken/vscode-gitlens/issues/2185) - Commits view files are sometimes not shown when expanding folders
- Fixes [#2180](https://github.com/gitkraken/vscode-gitlens/issues/2180) - Tree files view of commits is broken
- Fixes [#2179](https://github.com/gitkraken/vscode-gitlens/issues/2179) - Commit Graph content not displayed
- Fixes regression with _Contributors_ view not working

+ 28
- 29
src/views/nodes/branchNode.ts View File

@ -140,9 +140,8 @@ export class BranchNode
if (this._children == null) {
const branch = this.branch;
let pullRequest;
let onCompleted: Deferred<void> | undefined;
let pullRequest;
if (
this.view.config.pullRequests.enabled &&
@ -152,35 +151,35 @@ export class BranchNode
pullRequest = this.getState('pullRequest');
if (pullRequest === undefined && this.getState('pendingPullRequest') === undefined) {
onCompleted = defer<void>();
queueMicrotask(() => {
void this.getAssociatedPullRequest(
branch,
this.root ? { include: [PullRequestState.Open, PullRequestState.Merged] } : undefined,
).then(pr => {
onCompleted?.cancel();
// If we found a pull request, insert it into the children cache (if loaded) and refresh the node
if (pr != null && this._children != null) {
this._children.splice(
this._children[0] instanceof CompareBranchNode ? 1 : 0,
0,
new PullRequestNode(this.view, this, pr, branch),
);
}
// Refresh this node to show a spinner while the pull request is loading
this.view.triggerNodeChange(this);
});
// If we are showing the node, then refresh this node to show a spinner while the pull request is loading
if (!this.splatted) {
void onCompleted?.promise.then(
() => this.view.triggerNodeChange(this),
() => {},
const prPromise = this.getAssociatedPullRequest(
branch,
this.root ? { include: [PullRequestState.Open, PullRequestState.Merged] } : undefined,
);
queueMicrotask(async () => {
const [prResult] = await Promise.allSettled([prPromise, onCompleted?.promise]);
const pr = getSettledValue(prResult);
// If we found a pull request, insert it into the children cache (if loaded) and refresh the node
if (pr != null && this._children != null) {
this._children.splice(
this._children[0] instanceof CompareBranchNode ? 1 : 0,
0,
new PullRequestNode(this.view, this, pr, branch),
);
}
// Refresh this node to add or remove the pull request node
this.view.triggerNodeChange(this);
});
// // If we are showing the node, then refresh this node to show a spinner while the pull request is loading
// if (!this.splatted) {
// void onCompleted?.promise.then(
// () => this.view.triggerNodeChange(this),
// () => {},
// );
// }
}
}
@ -327,7 +326,7 @@ export class BranchNode
}
this._children = children;
setTimeout(() => onCompleted?.fulfill(), 0);
onCompleted?.fulfill();
}
return this._children;

+ 26
- 26
src/views/nodes/commitNode.ts View File

@ -72,10 +72,9 @@ export class CommitNode extends ViewRefNode
if (this._children == null) {
const commit = this.commit;
const pullRequest = this.getState('pullRequest');
let children: (PullRequestNode | FileNode)[] = [];
let onCompleted: Deferred<void> | undefined;
let pullRequest;
if (
!(this.view instanceof TagsView) &&
@ -83,32 +82,33 @@ export class CommitNode extends ViewRefNode
this.view.config.pullRequests.enabled &&
this.view.config.pullRequests.showForCommits
) {
pullRequest = this.getState('pullRequest');
if (pullRequest === undefined && this.getState('pendingPullRequest') === undefined) {
onCompleted = defer<void>();
queueMicrotask(() => {
void this.getAssociatedPullRequest(commit).then(pr => {
onCompleted?.cancel();
// If we found a pull request, insert it into the children cache (if loaded) and refresh the node
if (pr != null && this._children != null) {
this._children.splice(
0,
0,
new PullRequestNode(this.view as ViewsWithCommits, this, pr, commit),
);
}
// Refresh this node to show a spinner while the pull request is loading
this.view.triggerNodeChange(this);
});
// Refresh this node to show a spinner while the pull request is loading
void onCompleted?.promise.then(
() => this.view.triggerNodeChange(this),
() => {},
);
const prPromise = this.getAssociatedPullRequest(commit);
queueMicrotask(async () => {
const [prResult] = await Promise.allSettled([prPromise, onCompleted?.promise]);
const pr = getSettledValue(prResult);
// If we found a pull request, insert it into the children cache (if loaded) and refresh the node
if (pr != null && this._children != null) {
this._children.splice(
0,
0,
new PullRequestNode(this.view as ViewsWithCommits, this, pr, commit),
);
}
// Refresh this node to add or remove the pull request node
this.view.triggerNodeChange(this);
});
// // Refresh this node to show a spinner while the pull request is loading
// void onCompleted?.promise.then(
// () => this.view.triggerNodeChange(this),
// () => {},
// );
}
}
@ -136,7 +136,7 @@ export class CommitNode extends ViewRefNode
}
this._children = children;
setTimeout(() => onCompleted?.fulfill(), 1);
onCompleted?.fulfill();
}
return this._children;

+ 26
- 27
src/views/nodes/worktreeNode.ts View File

@ -11,7 +11,7 @@ import type { GitWorktree } from '../../git/models/worktree';
import { gate } from '../../system/decorators/gate';
import { debug } from '../../system/decorators/log';
import { map } from '../../system/iterable';
import type { Deferred} from '../../system/promise';
import type { Deferred } from '../../system/promise';
import { defer, getSettledValue } from '../../system/promise';
import { pad } from '../../system/string';
import type { RepositoriesView } from '../repositoriesView';
@ -65,9 +65,8 @@ export class WorktreeNode extends ViewNode
if (this._children == null) {
const branch = this._branch;
let pullRequest;
let onCompleted: Deferred<void> | undefined;
let pullRequest;
if (
branch != null &&
@ -78,34 +77,34 @@ export class WorktreeNode extends ViewNode
pullRequest = this.getState('pullRequest');
if (pullRequest === undefined && this.getState('pendingPullRequest') === undefined) {
onCompleted = defer<void>();
const prPromise = this.getAssociatedPullRequest(branch, {
include: [PullRequestState.Open, PullRequestState.Merged],
});
queueMicrotask(() => {
void this.getAssociatedPullRequest(branch, {
include: [PullRequestState.Open, PullRequestState.Merged],
}).then(pr => {
onCompleted?.cancel();
// If we found a pull request, insert it into the children cache (if loaded) and refresh the node
if (pr != null && this._children != null) {
this._children.splice(
this._children[0] instanceof CompareBranchNode ? 1 : 0,
0,
new PullRequestNode(this.view, this, pr, branch),
);
}
// Refresh this node to show a spinner while the pull request is loading
this.view.triggerNodeChange(this);
});
queueMicrotask(async () => {
const [prResult] = await Promise.allSettled([prPromise, onCompleted?.promise]);
// If we are showing the node, then refresh this node to show a spinner while the pull request is loading
if (!this.splatted) {
void onCompleted?.promise.then(
() => this.view.triggerNodeChange(this),
() => {},
const pr = getSettledValue(prResult);
// If we found a pull request, insert it into the children cache (if loaded) and refresh the node
if (pr != null && this._children != null) {
this._children.splice(
this._children[0] instanceof CompareBranchNode ? 1 : 0,
0,
new PullRequestNode(this.view, this, pr, branch),
);
}
// Refresh this node to add or remove the pull request node
this.view.triggerNodeChange(this);
});
// // If we are showing the node, then refresh this node to show a spinner while the pull request is loading
// if (!this.splatted) {
// void onCompleted?.promise.then(
// () => this.view.triggerNodeChange(this),
// () => {},
// );
// }
}
}
@ -179,7 +178,7 @@ export class WorktreeNode extends ViewNode
}
this._children = children;
setTimeout(() => onCompleted?.fulfill(), 0);
onCompleted?.fulfill();
}
return this._children;

Loading…
Cancel
Save