Ver a proveniência

Fixes #1844 - pages autolinked issues properly

main
Eric Amodio há 2 anos
ascendente
cometimento
d45df87996
8 ficheiros alterados com 60 adições e 26 eliminações
  1. +1
    -0
      CHANGELOG.md
  2. +15
    -2
      src/views/nodes/autolinkedItemsNode.ts
  3. +3
    -3
      src/views/nodes/branchNode.ts
  4. +20
    -11
      src/views/nodes/common.ts
  5. +15
    -5
      src/views/nodes/resultsCommitsNode.ts
  6. +3
    -3
      src/views/nodes/tagNode.ts
  7. +1
    -1
      src/views/nodes/viewNode.ts
  8. +2
    -1
      src/views/viewBase.ts

+ 1
- 0
CHANGELOG.md Ver ficheiro

@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed
- Fixes [#1844](https://github.com/gitkraken/vscode-gitlens/issues/1844) - Autolinked issues aren't properly paged when there are too many commits
- Fixes [#1843](https://github.com/gitkraken/vscode-gitlens/issues/1843) - Compare references doesn't work if you have multiple repos open
## [12.0.0] - 2022-02-28

+ 15
- 2
src/views/nodes/autolinkedItemsNode.ts Ver ficheiro

@ -7,7 +7,7 @@ import { debug } from '../../system/decorators/log';
import { PromiseCancelledErrorWithId } from '../../system/promise';
import { ViewsWithCommits } from '../viewBase';
import { AutolinkedItemNode } from './autolinkedItemNode';
import { MessageNode } from './common';
import { LoadMoreNode, MessageNode } from './common';
import { PullRequestNode } from './pullRequestNode';
import { ContextValues, ViewNode } from './viewNode';
@ -32,6 +32,7 @@ export class AutolinkedItemsNode extends ViewNode {
public readonly repoPath: string,
public readonly remote: GitRemote<RichRemoteProvider>,
public readonly log: GitLog,
private expand: boolean,
) {
super(GitUri.fromRepoPath(repoPath), view, parent);
this._instanceId = instanceId++;
@ -82,13 +83,25 @@ export class AutolinkedItemsNode extends ViewNode {
children = [new MessageNode(this.view, this, 'No autolinked issues or pull requests could be found.')];
}
if (this.log.hasMore) {
children.push(
new LoadMoreNode(this.view, this.parent as any, children[children.length - 1], {
context: { expandAutolinks: true },
message: 'Load more commits to search for autolinks',
}),
);
}
this._children = children;
}
return this._children;
}
getTreeItem(): TreeItem {
const item = new TreeItem('Autolinked Issues and Pull Requests', TreeItemCollapsibleState.Collapsed);
const item = new TreeItem(
'Autolinked Issues and Pull Requests',
this.expand ? TreeItemCollapsibleState.Expanded : TreeItemCollapsibleState.Collapsed,
);
item.id = this.id;
item.contextValue = ContextValues.AutolinkedItems;

+ 3
- 3
src/views/nodes/branchNode.ts Ver ficheiro

@ -267,9 +267,9 @@ export class BranchNode
if (log.hasMore) {
children.push(
new LoadMoreNode(this.view, this, children[children.length - 1], undefined, () =>
this.view.container.git.getCommitCount(this.branch.repoPath, this.branch.name),
),
new LoadMoreNode(this.view, this, children[children.length - 1], {
getCount: () => this.view.container.git.getCommitCount(this.branch.repoPath, this.branch.name),
}),
);
}

+ 20
- 11
src/views/nodes/common.ts Ver ficheiro

@ -146,26 +146,31 @@ export abstract class PagerNode extends ViewNode {
parent: ViewNode & PageableViewNode,
protected readonly message: string,
protected readonly previousNode?: ViewNode,
protected readonly pageSize: number = Container.instance.config.views.pageItemLimit,
protected readonly countFn?: () => Promise<number | undefined>,
protected readonly options?: {
context?: Record<string, unknown>;
pageSize?: number;
getCount?: () => Promise<number | undefined>;
}, // protected readonly pageSize: number = Container.instance.config.views.pageItemLimit, // protected readonly countFn?: () => Promise<number | undefined>, // protected readonly context?: Record<string, unknown>, // protected readonly beforeLoadCallback?: (mode: 'all' | 'more') => void,
) {
super(GitUri.unknown, view, parent);
}
async loadAll() {
const count = (await this.countFn?.()) ?? 0;
const count = (await this.options?.getCount?.()) ?? 0;
return this.view.loadMoreNodeChildren(
this.parent! as ViewNode & PageableViewNode,
count > 5000 ? 5000 : 0,
this.previousNode,
this.options?.context,
);
}
loadMore() {
return this.view.loadMoreNodeChildren(
this.parent! as ViewNode & PageableViewNode,
this.pageSize,
this.options?.pageSize ?? Container.instance.config.views.pageItemLimit,
this.previousNode,
this.options?.context,
);
}
@ -194,18 +199,22 @@ export class LoadMoreNode extends PagerNode {
view: View,
parent: ViewNode & PageableViewNode,
previousNode: ViewNode,
pageSize?: number,
countFn?: () => Promise<number | undefined>,
options?: {
context?: Record<string, unknown>;
getCount?: () => Promise<number | undefined>;
message?: string;
pageSize?: number;
},
) {
super(
view,
parent,
pageSize === 0
? `Load all ${GlyphChars.Space}${GlyphChars.Dash}${GlyphChars.Space} this may take a while`
: 'Load more',
options?.message ??
(options?.pageSize === 0
? `Load all ${GlyphChars.Space}${GlyphChars.Dash}${GlyphChars.Space} this may take a while`
: 'Load more'),
previousNode,
pageSize,
countFn,
options,
);
}
}

+ 15
- 5
src/views/nodes/resultsCommitsNode.ts Ver ficheiro

@ -71,12 +71,18 @@ export class ResultsCommitsNode
const { log } = await this.getCommitsQueryResults();
if (log == null) return [];
const getBranchAndTagTips = await this.view.container.git.getBranchesAndTagsTipsFn(this.uri.repoPath);
const [getBranchAndTagTips, provider] = await Promise.all([
this.view.container.git.getBranchesAndTagsTipsFn(this.uri.repoPath),
this.view.container.git.getRichRemoteProvider(this.repoPath),
]);
const children = [];
const remote = await this.view.container.git.getRichRemoteProvider(this.repoPath);
if (remote != null) {
children.push(new AutolinkedItemsNode(this.view, this, this.uri.repoPath!, remote, log));
if (provider != null) {
children.push(
new AutolinkedItemsNode(this.view, this, this.uri.repoPath!, provider, log, this._expandAutolinks),
);
this._expandAutolinks = false;
}
const { files } = this._results;
@ -188,11 +194,15 @@ export class ResultsCommitsNode
return this._hasMore;
}
private _expandAutolinks: boolean = false;
limit: number | undefined = this.view.getNodeLastKnownLimit(this);
async loadMore(limit?: number) {
async loadMore(limit?: number, context?: Record<string, unknown>): Promise<void> {
const results = await this.getCommitsQueryResults();
if (results == null || !results.hasMore) return;
if (context != null && 'expandAutolinks' in context) {
this._expandAutolinks = Boolean(context.expandAutolinks);
}
await results.more?.(limit ?? this.view.config.pageItemLimit);
this.limit = results.log?.count;

+ 3
- 3
src/views/nodes/tagNode.ts Ver ficheiro

@ -63,9 +63,9 @@ export class TagNode extends ViewRefNode
if (log.hasMore) {
children.push(
new LoadMoreNode(this.view, this, children[children.length - 1], undefined, () =>
this.view.container.git.getCommitCount(this.tag.repoPath, this.tag.name),
),
new LoadMoreNode(this.view, this, children[children.length - 1], {
getCount: () => this.view.container.git.getCommitCount(this.tag.repoPath, this.tag.name),
}),
);
}
return children;

+ 1
- 1
src/views/nodes/viewNode.ts Ver ficheiro

@ -177,7 +177,7 @@ export interface PageableViewNode {
readonly id: string;
limit?: number;
readonly hasMore: boolean;
loadMore(limit?: number | { until?: string | undefined }): Promise<void>;
loadMore(limit?: number | { until?: string | undefined }, context?: Record<string, unknown>): Promise<void>;
}
export namespace PageableViewNode {

+ 2
- 1
src/views/viewBase.ts Ver ficheiro

@ -533,12 +533,13 @@ export abstract class ViewBase<
node: ViewNode & PageableViewNode,
limit: number | { until: string | undefined } | undefined,
previousNode?: ViewNode,
context?: Record<string, unknown>,
) {
if (previousNode != null) {
void (await this.reveal(previousNode, { select: true }));
}
await node.loadMore(limit);
await node.loadMore(limit, context);
this._lastKnownLimits.set(node.id, node.limit);
}

Carregando…
Cancelar
Guardar