Parcourir la source

Fixes #2742 avoids refresh while laoding children

main
Eric Amodio il y a 1 an
Parent
révision
5dc1c87164
2 fichiers modifiés avec 32 ajouts et 7 suppressions
  1. +1
    -0
      CHANGELOG.md
  2. +31
    -7
      src/views/nodes/resultsCommitsNode.ts

+ 1
- 0
CHANGELOG.md Voir le fichier

@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed
- Fixes [2742](https://github.com/gitkraken/vscode-gitlens/issues/2742) - Search & Compare: Element with id ... is already registered
- Fixes an issue where the links in the _Search & Compare_ view failed to open the specific search type
- Fixes an issue when searching for commits and the results contain stashes

+ 31
- 7
src/views/nodes/resultsCommitsNode.ts Voir le fichier

@ -6,7 +6,8 @@ import { configuration } from '../../system/configuration';
import { gate } from '../../system/decorators/gate';
import { debug } from '../../system/decorators/log';
import { map } from '../../system/iterable';
import { cancellable, PromiseCancelledError } from '../../system/promise';
import type { Deferred } from '../../system/promise';
import { cancellable, defer, PromiseCancelledError } from '../../system/promise';
import type { ViewsWithCommits } from '../viewBase';
import { AutolinkedItemsNode } from './autolinkedItemsNode';
import { CommitNode } from './commitNode';
@ -76,7 +77,12 @@ export class ResultsCommitsNode
return this._results.comparison?.ref2;
}
private _onChildrenCompleted: Deferred<void> | undefined;
async getChildren(): Promise<ViewNode[]> {
this._onChildrenCompleted?.cancel();
this._onChildrenCompleted = defer<void>();
const { log } = await this.getCommitsQueryResults();
if (log == null) return [];
@ -126,6 +132,7 @@ export class ResultsCommitsNode
children.push(new LoadMoreNode(this.view, this, children[children.length - 1]));
}
this._onChildrenCompleted.fulfill();
return children;
}
@ -148,7 +155,14 @@ export class ResultsCommitsNode
: TreeItemCollapsibleState.Collapsed;
} catch (ex) {
if (ex instanceof PromiseCancelledError) {
ex.promise.then(() => this.triggerChange(false));
setTimeout(async () => {
void (await ex.promise);
try {
await this._onChildrenCompleted?.promise;
} catch {}
setTimeout(() => void this.triggerChange(false), 1);
}, 1);
}
// Need to use Collapsed before we have results or the item won't show up in the view until the children are awaited
@ -171,24 +185,34 @@ export class ResultsCommitsNode
override refresh(reset: boolean = false) {
if (reset) {
this._commitsQueryResults = undefined;
this._commitsQueryResultsPromise = undefined;
void this.getCommitsQueryResults();
}
}
private _commitsQueryResults: Promise<CommitsQueryResults> | undefined;
private _commitsQueryResultsPromise: Promise<CommitsQueryResults> | undefined;
private async getCommitsQueryResults() {
if (this._commitsQueryResults == null) {
this._commitsQueryResults = this._results.query(this.limit ?? configuration.get('advanced.maxSearchItems'));
const results = await this._commitsQueryResults;
if (this._commitsQueryResultsPromise == null) {
this._commitsQueryResultsPromise = this._results.query(
this.limit ?? configuration.get('advanced.maxSearchItems'),
);
const results = await this._commitsQueryResultsPromise;
this._commitsQueryResults = results;
this._hasMore = results.hasMore;
if (this._results.deferred) {
this._results.deferred = false;
void this.triggerChange(false);
// void this.triggerChange(false);
}
}
return this._commitsQueryResultsPromise;
}
private _commitsQueryResults: CommitsQueryResults | undefined;
private maybeGetCommitsQueryResults(): CommitsQueryResults | undefined {
return this._commitsQueryResults;
}

Chargement…
Annuler
Enregistrer