diff --git a/package.json b/package.json index e1642e8..fa32371 100644 --- a/package.json +++ b/package.json @@ -3293,12 +3293,12 @@ "icon": "$(refresh)" }, { - "command": "gitlens.views.showMoreChildren", + "command": "gitlens.views.loadMoreChildren", "title": "Load More", "category": "GitLens" }, { - "command": "gitlens.views.showAllChildren", + "command": "gitlens.views.loadAllChildren", "title": "Load All", "category": "GitLens", "icon": { @@ -4564,11 +4564,11 @@ "when": "false" }, { - "command": "gitlens.views.showMoreChildren", + "command": "gitlens.views.loadMoreChildren", "when": "false" }, { - "command": "gitlens.views.showAllChildren", + "command": "gitlens.views.loadAllChildren", "when": "false" }, { @@ -6755,12 +6755,12 @@ "group": "9_gitlens@99" }, { - "command": "gitlens.views.showAllChildren", + "command": "gitlens.views.loadAllChildren", "when": "viewItem =~ /gitlens:pager\\b/", "group": "inline@1" }, { - "command": "gitlens.views.showAllChildren", + "command": "gitlens.views.loadAllChildren", "when": "viewItem =~ /gitlens:pager\\b/", "group": "1_gitlens_actions@1" } diff --git a/src/views/branchesView.ts b/src/views/branchesView.ts index f664c6e..9dc6835 100644 --- a/src/views/branchesView.ts +++ b/src/views/branchesView.ts @@ -283,7 +283,7 @@ export class BranchesView extends ViewBase } if (n instanceof BranchNode && branches.includes(n.branch.name)) { - await n.showMore({ until: commit.ref }); + await n.loadMore({ until: commit.ref }); return true; } diff --git a/src/views/commitsView.ts b/src/views/commitsView.ts index 19198d0..ad3329f 100644 --- a/src/views/commitsView.ts +++ b/src/views/commitsView.ts @@ -307,7 +307,7 @@ export class CommitsView extends ViewBase { if (node instanceof CommitsRepositoryNode) { node = await node.getSplattedChild?.(); if (node instanceof BranchNode) { - await node.showMore({ until: commit.ref }); + await node.loadMore({ until: commit.ref }); } } @@ -318,7 +318,7 @@ export class CommitsView extends ViewBase { if (n.id.startsWith(repoNodeId)) { const node = await n.getSplattedChild?.(); if (node instanceof BranchNode) { - await node.showMore({ until: commit.ref }); + await node.loadMore({ until: commit.ref }); return true; } } diff --git a/src/views/nodes/branchNode.ts b/src/views/nodes/branchNode.ts index 8adf82b..b382f80 100644 --- a/src/views/nodes/branchNode.ts +++ b/src/views/nodes/branchNode.ts @@ -4,7 +4,7 @@ import { BranchesView } from '../branchesView'; import { BranchTrackingStatusNode } from './branchTrackingStatusNode'; import { CommitNode } from './commitNode'; import { CommitsView } from '../commitsView'; -import { MessageNode, ShowMoreNode } from './common'; +import { LoadMoreNode, MessageNode } from './common'; import { ViewBranchesLayout } from '../../configuration'; import { GlyphChars } from '../../constants'; import { Container } from '../../container'; @@ -151,7 +151,7 @@ export class BranchNode ); if (log.hasMore) { - children.push(new ShowMoreNode(this.view, this, children[children.length - 1])); + children.push(new LoadMoreNode(this.view, this, children[children.length - 1])); } this._children = children; @@ -297,7 +297,7 @@ export class BranchNode } limit: number | undefined = this.view.getNodeLastKnownLimit(this); - async showMore(limit?: number | { until?: any }) { + async loadMore(limit?: number | { until?: any }) { let log = await this.getLog(); if (log == null || !log.hasMore) return; diff --git a/src/views/nodes/branchTrackingStatusNode.ts b/src/views/nodes/branchTrackingStatusNode.ts index fa53545..f05a2e2 100644 --- a/src/views/nodes/branchTrackingStatusNode.ts +++ b/src/views/nodes/branchTrackingStatusNode.ts @@ -3,7 +3,7 @@ import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode'; import { BranchNode } from './branchNode'; import { BranchTrackingStatusFilesNode } from './branchTrackingStatusFilesNode'; import { CommitNode } from './commitNode'; -import { ShowMoreNode } from './common'; +import { LoadMoreNode } from './common'; import { Container } from '../../container'; import { GitBranch, GitLog, GitRevision, GitTrackingState } from '../../git/git'; import { GitUri } from '../../git/gitUri'; @@ -94,7 +94,7 @@ export class BranchTrackingStatusNode extends ViewNode implement } if (log.hasMore) { - children.push(new ShowMoreNode(this.view, this, children[children.length - 1])); + children.push(new LoadMoreNode(this.view, this, children[children.length - 1])); } if (!this.isReposView && this.status.upstream && this.upstreamType === 'ahead' && this.status.state.ahead > 0) { @@ -232,7 +232,7 @@ export class BranchTrackingStatusNode extends ViewNode implement } limit: number | undefined = this.view.getNodeLastKnownLimit(this); - async showMore(limit?: number | { until?: any }) { + async loadMore(limit?: number | { until?: any }) { let log = await this.getLog(); if (log == null || !log.hasMore) return; diff --git a/src/views/nodes/common.ts b/src/views/nodes/common.ts index 8a2b56e..2f45828 100644 --- a/src/views/nodes/common.ts +++ b/src/views/nodes/common.ts @@ -140,22 +140,22 @@ export abstract class PagerNode extends ViewNode { view: View, parent: ViewNode & PageableViewNode, protected readonly message: string, - private readonly _previousNode?: ViewNode, - private readonly _pageSize: number = Container.config.views.pageItemLimit, + protected readonly previousNode?: ViewNode, + protected readonly pageSize: number = Container.config.views.pageItemLimit, ) { super(unknownGitUri, view, parent); } - showMore() { - return this.view.showMoreNodeChildren( - this.parent! as ViewNode & PageableViewNode, - this._pageSize, - this._previousNode, - ); + loadAll() { + return this.view.loadMoreNodeChildren(this.parent! as ViewNode & PageableViewNode, 0, this.previousNode); } - showAll() { - return this.view.showMoreNodeChildren(this.parent! as ViewNode & PageableViewNode, 0, this._previousNode); + loadMore() { + return this.view.loadMoreNodeChildren( + this.parent! as ViewNode & PageableViewNode, + this.pageSize, + this.previousNode, + ); } getChildren(): ViewNode[] | Promise { @@ -172,13 +172,13 @@ export abstract class PagerNode extends ViewNode { getCommand(): Command | undefined { return { title: 'Load more', - command: 'gitlens.views.showMoreChildren', + command: 'gitlens.views.loadMoreChildren', arguments: [this], }; } } -export class ShowMoreNode extends PagerNode { +export class LoadMoreNode extends PagerNode { constructor(view: View, parent: ViewNode & PageableViewNode, previousNode: ViewNode, pageSize?: number) { super( view, diff --git a/src/views/nodes/contributorNode.ts b/src/views/nodes/contributorNode.ts index 41c8652..6a3e372 100644 --- a/src/views/nodes/contributorNode.ts +++ b/src/views/nodes/contributorNode.ts @@ -1,7 +1,7 @@ 'use strict'; import { TreeItem, TreeItemCollapsibleState } from 'vscode'; import { CommitNode } from './commitNode'; -import { MessageNode, ShowMoreNode } from './common'; +import { LoadMoreNode, MessageNode } from './common'; import { GlyphChars } from '../../constants'; import { Container } from '../../container'; import { ContributorsView } from '../contributorsView'; @@ -54,7 +54,7 @@ export class ContributorNode extends ViewNode implements PageableViewNode { static key = ':reflog'; @@ -38,7 +38,7 @@ export class ReflogNode extends ViewNode implements PageableVi children.push(...reflog.records.map(r => new ReflogRecordNode(this.view, this, r))); if (reflog.hasMore) { - children.push(new ShowMoreNode(this.view, this, children[children.length - 1])); + children.push(new LoadMoreNode(this.view, this, children[children.length - 1])); } this._children = children; @@ -85,7 +85,7 @@ export class ReflogNode extends ViewNode implements PageableVi } limit: number | undefined = this.view.getNodeLastKnownLimit(this); - async showMore(limit?: number) { + async loadMore(limit?: number) { let reflog = await this.getReflog(); if (reflog === undefined || !reflog.hasMore) return; diff --git a/src/views/nodes/reflogRecordNode.ts b/src/views/nodes/reflogRecordNode.ts index 9541244..9524432 100644 --- a/src/views/nodes/reflogRecordNode.ts +++ b/src/views/nodes/reflogRecordNode.ts @@ -1,15 +1,15 @@ 'use strict'; import { TreeItem, TreeItemCollapsibleState } from 'vscode'; +import { CommitNode } from './commitNode'; +import { LoadMoreNode, MessageNode } from './common'; import { GlyphChars } from '../../constants'; import { Container } from '../../container'; import { GitLog, GitReflogRecord } from '../../git/git'; import { GitUri } from '../../git/gitUri'; +import { RepositoryNode } from './repositoryNode'; import { debug, gate, Iterables } from '../../system'; import { ViewsWithFiles } from '../viewBase'; -import { CommitNode } from './commitNode'; -import { MessageNode, ShowMoreNode } from './common'; import { ContextValues, PageableViewNode, ViewNode } from './viewNode'; -import { RepositoryNode } from './repositoryNode'; export class ReflogRecordNode extends ViewNode implements PageableViewNode { static key = ':reflog-record'; @@ -45,12 +45,12 @@ export class ReflogRecordNode extends ViewNode implements Pageab const log = await this.getLog(); if (log === undefined) return [new MessageNode(this.view, this, 'No commits could be found.')]; - const children: (CommitNode | ShowMoreNode)[] = [ + const children: (CommitNode | LoadMoreNode)[] = [ ...Iterables.map(log.commits.values(), c => new CommitNode(this.view, this, c)), ]; if (log.hasMore) { - children.push(new ShowMoreNode(this.view, this, children[children.length - 1])); + children.push(new LoadMoreNode(this.view, this, children[children.length - 1])); } return children; } @@ -104,7 +104,7 @@ export class ReflogRecordNode extends ViewNode implements Pageab } limit: number | undefined = this.view.getNodeLastKnownLimit(this); - async showMore(limit?: number | { until?: any }) { + async loadMore(limit?: number | { until?: any }) { let log = await this.getLog(); if (log === undefined || !log.hasMore) return; diff --git a/src/views/nodes/resultsCommitsNode.ts b/src/views/nodes/resultsCommitsNode.ts index 5eb104a..dd0cd21 100644 --- a/src/views/nodes/resultsCommitsNode.ts +++ b/src/views/nodes/resultsCommitsNode.ts @@ -1,13 +1,13 @@ 'use strict'; import { TreeItem, TreeItemCollapsibleState } from 'vscode'; +import { CommitNode } from './commitNode'; +import { LoadMoreNode } from './common'; import { Container } from '../../container'; import { GitLog } from '../../git/git'; import { GitUri } from '../../git/gitUri'; +import { insertDateMarkers } from './helpers'; import { debug, gate, Iterables, Promises } from '../../system'; import { ViewsWithFiles } from '../viewBase'; -import { CommitNode } from './commitNode'; -import { ShowMoreNode } from './common'; -import { insertDateMarkers } from './helpers'; import { ContextValues, PageableViewNode, ViewNode } from './viewNode'; export interface CommitsQueryResults { @@ -59,7 +59,7 @@ export class ResultsCommitsNode extends ViewNode implements Page ]; if (log.hasMore) { - children.push(new ShowMoreNode(this.view, this, children[children.length - 1])); + children.push(new LoadMoreNode(this.view, this, children[children.length - 1])); } return children; @@ -128,7 +128,7 @@ export class ResultsCommitsNode extends ViewNode implements Page } limit: number | undefined = this.view.getNodeLastKnownLimit(this); - async showMore(limit?: number) { + async loadMore(limit?: number) { const results = await this.getCommitsQueryResults(); if (results === undefined || !results.hasMore) return; diff --git a/src/views/nodes/tagNode.ts b/src/views/nodes/tagNode.ts index d5426c1..8dee65f 100644 --- a/src/views/nodes/tagNode.ts +++ b/src/views/nodes/tagNode.ts @@ -1,19 +1,19 @@ 'use strict'; import { TreeItem, TreeItemCollapsibleState } from 'vscode'; +import { CommitNode } from './commitNode'; +import { LoadMoreNode, MessageNode } from './common'; import { ViewBranchesLayout } from '../../configuration'; +import { GlyphChars } from '../../constants'; import { Container } from '../../container'; +import { emojify } from '../../emojis'; import { GitLog, GitRevision, GitTag, GitTagReference, TagDateFormatting } from '../../git/git'; import { GitUri } from '../../git/gitUri'; -import { debug, gate, Iterables, Strings } from '../../system'; import { RepositoriesView } from '../repositoriesView'; -import { CommitNode } from './commitNode'; -import { MessageNode, ShowMoreNode } from './common'; import { insertDateMarkers } from './helpers'; -import { ContextValues, PageableViewNode, ViewNode, ViewRefNode } from './viewNode'; -import { emojify } from '../../emojis'; import { RepositoryNode } from './repositoryNode'; -import { GlyphChars } from '../../constants'; +import { debug, gate, Iterables, Strings } from '../../system'; import { TagsView } from '../tagsView'; +import { ContextValues, PageableViewNode, ViewNode, ViewRefNode } from './viewNode'; export class TagNode extends ViewRefNode implements PageableViewNode { static key = ':tag'; @@ -57,7 +57,7 @@ export class TagNode extends ViewRefNode; + loadMore(limit?: number | { until?: any }): Promise; } export namespace PageableViewNode { export function is(node: ViewNode): node is ViewNode & PageableViewNode { - return Functions.is(node, 'showMore'); + return Functions.is(node, 'loadMore'); } } diff --git a/src/views/repositoriesView.ts b/src/views/repositoriesView.ts index cf1587c..5cb0b89 100644 --- a/src/views/repositoriesView.ts +++ b/src/views/repositoriesView.ts @@ -194,7 +194,7 @@ export class RepositoriesView extends ViewBase n.toString() }, singleLine: true }) - resetNodeLastKnownLimit(node: PageableViewNode) { - this._lastKnownLimits.delete(node.id); - } - @debug({ args: { 0: (n: ViewNode & PageableViewNode) => n.toString(), 3: (n?: ViewNode) => (n == null ? '' : n.toString()), }, }) - async showMoreNodeChildren( + async loadMoreNodeChildren( node: ViewNode & PageableViewNode, limit: number | { until: any } | undefined, previousNode?: ViewNode, @@ -550,10 +545,15 @@ export abstract class ViewBase< void (await this.reveal(previousNode, { select: true })); } - await node.showMore(limit); + await node.loadMore(limit); this._lastKnownLimits.set(node.id, node.limit); } + @debug({ args: { 0: (n: ViewNode) => n.toString() }, singleLine: true }) + resetNodeLastKnownLimit(node: PageableViewNode) { + this._lastKnownLimits.delete(node.id); + } + @debug({ args: { 0: (n: ViewNode) => (n != null ? n.toString() : '') }, }) diff --git a/src/views/viewCommands.ts b/src/views/viewCommands.ts index 7d7c891..8e6d76f 100644 --- a/src/views/viewCommands.ts +++ b/src/views/viewCommands.ts @@ -90,8 +90,8 @@ export class ViewCommands { this, ); commands.registerCommand('gitlens.views.executeNodeCallback', (fn: () => Promise) => fn(), this); - commands.registerCommand('gitlens.views.showMoreChildren', (node: PagerNode) => node.showMore(), this); - commands.registerCommand('gitlens.views.showAllChildren', (node: PagerNode) => node.showAll(), this); + commands.registerCommand('gitlens.views.loadMoreChildren', (node: PagerNode) => node.loadMore(), this); + commands.registerCommand('gitlens.views.loadAllChildren', (node: PagerNode) => node.loadAll(), this); commands.registerCommand('gitlens.views.fetch', this.fetch, this); commands.registerCommand('gitlens.views.publishBranch', this.publishBranch, this);