Skip to content

Commit

Permalink
Persists show more during changes
Browse files Browse the repository at this point in the history
Fixes show more in file/line history
  • Loading branch information
eamodio committed Jun 11, 2019
1 parent 578f103 commit a402de3
Show file tree
Hide file tree
Showing 14 changed files with 173 additions and 90 deletions.
13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2978,6 +2978,15 @@
"light": "images/light/icon-refresh.svg"
}
},
{
"command": "gitlens.views.showMoreChildren",
"title": "Show More",
"category": "GitLens",
"icon": {
"dark": "images/dark/icon-unfold.svg",
"light": "images/light/icon-unfold.svg"
}
},
{
"command": "gitlens.views.showAllChildren",
"title": "Show All",
Expand Down Expand Up @@ -3646,6 +3655,10 @@
"command": "gitlens.views.refreshNode",
"when": "false"
},
{
"command": "gitlens.views.showMoreChildren",
"when": "false"
},
{
"command": "gitlens.views.showAllChildren",
"when": "false"
Expand Down
11 changes: 7 additions & 4 deletions src/views/nodes/branchNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import { getBranchesAndTagTipsFn, insertDateMarkers } from './helpers';
import { PageableViewNode, ResourceType, ViewNode, ViewRefNode } from './viewNode';

export class BranchNode extends ViewRefNode<RepositoriesView> implements PageableViewNode {
readonly supportsPaging: boolean = true;
maxCount: number | undefined;
readonly supportsPaging = true;
readonly rememberLastMaxCount = true;
maxCount: number | undefined = this.view.getNodeLastMaxCount(this);

private _children: ViewNode[] | undefined;

Expand Down Expand Up @@ -94,7 +95,9 @@ export class BranchNode extends ViewRefNode<RepositoriesView> implements Pageabl
);

if (log.truncated) {
children.push(new ShowMoreNode(this.view, this, 'Commits', children[children.length - 1]));
children.push(
new ShowMoreNode(this.view, this, 'Commits', log.maxCount, children[children.length - 1])
);
}

this._children = children;
Expand Down Expand Up @@ -204,7 +207,7 @@ export class BranchNode extends ViewRefNode<RepositoriesView> implements Pageabl

@gate()
@debug()
refresh(reset: boolean = false) {
refresh() {
this._children = undefined;
}
}
7 changes: 4 additions & 3 deletions src/views/nodes/branchTrackingStatusNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ export interface BranchTrackingStatus {
}

export class BranchTrackingStatusNode extends ViewNode<ViewWithFiles> implements PageableViewNode {
readonly supportsPaging: boolean = true;
maxCount: number | undefined;
readonly supportsPaging = true;
readonly rememberLastMaxCount = true;
maxCount: number | undefined = this.view.getNodeLastMaxCount(this);

constructor(
view: ViewWithFiles,
Expand Down Expand Up @@ -74,7 +75,7 @@ export class BranchTrackingStatusNode extends ViewNode<ViewWithFiles> implements
}

if (log.truncated) {
children.push(new ShowMoreNode(this.view, this, 'Commits', children[children.length - 1]));
children.push(new ShowMoreNode(this.view, this, 'Commits', log.maxCount, children[children.length - 1]));
}
return children;
}
Expand Down
45 changes: 29 additions & 16 deletions src/views/nodes/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { Command, ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri } from 'vsc
import { GlyphChars } from '../../constants';
import { Container } from '../../container';
import { View } from '../viewBase';
import { RefreshNodeCommandArgs } from '../viewCommands';
import { ResourceType, unknownGitUri, ViewNode } from './viewNode';
import { PageableViewNode, ResourceType, unknownGitUri, ViewNode } from './viewNode';

export class MessageNode extends ViewNode {
constructor(
Expand Down Expand Up @@ -137,23 +136,29 @@ export class UpdateableMessageNode extends ViewNode {
}

export abstract class PagerNode extends ViewNode {
protected _args: RefreshNodeCommandArgs = {};

constructor(
view: View,
parent: ViewNode,
parent: ViewNode & PageableViewNode,
protected readonly message: string,
previousNode?: ViewNode,
maxCount: number = Container.config.views.pageItemLimit
maxCount: number | undefined,
private readonly _previousNode?: ViewNode,
private readonly _pageSize: number = Container.config.views.pageItemLimit
) {
super(unknownGitUri, view, parent);

this._args.maxCount = maxCount;
this._args.previousNode = previousNode;
parent.maxCount = maxCount;
}

showMore() {
return this.view.showMoreNodeChildren(
this.parent! as ViewNode & PageableViewNode,
this._pageSize,
this._previousNode
);
}

showAll() {
this.view.refreshNode(this.parent!, true, { ...this._args, maxCount: 0 });
return this.view.showMoreNodeChildren(this.parent! as ViewNode & PageableViewNode, 0, this._previousNode);
}

getChildren(): ViewNode[] | Promise<ViewNode[]> {
Expand All @@ -173,23 +178,31 @@ export abstract class PagerNode extends ViewNode {

getCommand(): Command | undefined {
return {
title: 'Refresh',
command: 'gitlens.views.refreshNode',
arguments: [this.parent, true, this._args]
title: 'Show More',
command: 'gitlens.views.showMoreChildren',
arguments: [this]
};
}
}

export class ShowMoreNode extends PagerNode {
constructor(view: View, parent: ViewNode, itemType: string, previousNode: ViewNode, maxCount?: number) {
constructor(
view: View,
parent: ViewNode & PageableViewNode,
itemType: string,
maxCount: number | undefined,
previousNode: ViewNode,
pageSize?: number
) {
super(
view,
parent,
maxCount === 0
pageSize === 0
? `Show All ${itemType} ${GlyphChars.Space}${GlyphChars.Dash}${GlyphChars.Space} this may take a while`
: `Show More ${itemType}`,
maxCount,
previousNode,
maxCount
pageSize
);
}
}
7 changes: 4 additions & 3 deletions src/views/nodes/contributorNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import { CommitNode } from './commitNode';
import { GlyphChars } from '../../constants';

export class ContributorNode extends ViewNode<RepositoriesView> implements PageableViewNode {
readonly supportsPaging: boolean = true;
maxCount: number | undefined;
readonly supportsPaging = true;
readonly rememberLastMaxCount = true;
maxCount: number | undefined = this.view.getNodeLastMaxCount(this);

constructor(uri: GitUri, view: RepositoriesView, parent: ViewNode, public readonly contributor: GitContributor) {
super(uri, view, parent);
Expand Down Expand Up @@ -41,7 +42,7 @@ export class ContributorNode extends ViewNode<RepositoriesView> implements Pagea
];

if (log.truncated) {
children.push(new ShowMoreNode(this.view, this, 'Commits', children[children.length - 1]));
children.push(new ShowMoreNode(this.view, this, 'Commits', log.maxCount, children[children.length - 1]));
}
return children;
}
Expand Down
6 changes: 4 additions & 2 deletions src/views/nodes/fileHistoryNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { insertDateMarkers } from './helpers';
import { PageableViewNode, ResourceType, SubscribeableViewNode, ViewNode } from './viewNode';

export class FileHistoryNode extends SubscribeableViewNode implements PageableViewNode {
readonly supportsPaging: boolean = true;
readonly supportsPaging = true;
maxCount: number | undefined;

constructor(uri: GitUri, view: View, parent: ViewNode) {
Expand Down Expand Up @@ -89,7 +89,9 @@ export class FileHistoryNode extends SubscribeableViewNode implements PageableVi
);

if (log.truncated) {
children.push(new ShowMoreNode(this.view, this, 'Commits', children[children.length - 1]));
children.push(
new ShowMoreNode(this.view, this, 'Commits', log.maxCount, children[children.length - 1])
);
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/views/nodes/lineHistoryNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { insertDateMarkers } from './helpers';
import { PageableViewNode, ResourceType, SubscribeableViewNode, ViewNode } from './viewNode';

export class LineHistoryNode extends SubscribeableViewNode implements PageableViewNode {
readonly supportsPaging: boolean = true;
readonly supportsPaging = true;
maxCount: number | undefined;

constructor(
Expand Down Expand Up @@ -111,7 +111,9 @@ export class LineHistoryNode extends SubscribeableViewNode implements PageableVi
);

if (log.truncated) {
children.push(new ShowMoreNode(this.view, this, 'Commits', children[children.length - 1]));
children.push(
new ShowMoreNode(this.view, this, 'Commits', log.maxCount, children[children.length - 1])
);
}
}

Expand Down
9 changes: 6 additions & 3 deletions src/views/nodes/reflogNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import { debug, gate } from '../../system';
import { MessageNode, ShowMoreNode } from './common';

export class ReflogNode extends ViewNode<RepositoriesView> implements PageableViewNode {
readonly supportsPaging: boolean = true;
maxCount: number | undefined;
readonly supportsPaging = true;
readonly rememberLastMaxCount = true;
maxCount: number | undefined = this.view.getNodeLastMaxCount(this);

private _children: ViewNode[] | undefined;

Expand All @@ -37,7 +38,9 @@ export class ReflogNode extends ViewNode<RepositoriesView> implements PageableVi
children.push(...reflog.records.map(r => new ReflogRecordNode(this.view, this, r)));

if (reflog.truncated) {
children.push(new ShowMoreNode(this.view, this, 'Activity', children[children.length - 1]));
children.push(
new ShowMoreNode(this.view, this, 'Activity', reflog.maxCount, children[children.length - 1])
);
}

this._children = children;
Expand Down
7 changes: 4 additions & 3 deletions src/views/nodes/reflogRecordNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import { MessageNode, ShowMoreNode } from './common';
import { PageableViewNode, ResourceType, ViewNode } from './viewNode';

export class ReflogRecordNode extends ViewNode<ViewWithFiles> implements PageableViewNode {
readonly supportsPaging: boolean = true;
maxCount: number | undefined;
readonly supportsPaging = true;
readonly rememberLastMaxCount = true;
maxCount: number | undefined = this.view.getNodeLastMaxCount(this);

constructor(view: ViewWithFiles, parent: ViewNode, public readonly record: GitReflogRecord) {
super(GitUri.fromRepoPath(record.repoPath), view, parent);
Expand All @@ -37,7 +38,7 @@ export class ReflogRecordNode extends ViewNode<ViewWithFiles> implements Pageabl
];

if (log.truncated) {
children.push(new ShowMoreNode(this.view, this, 'Commits', children[children.length - 1]));
children.push(new ShowMoreNode(this.view, this, 'Commits', log.maxCount, children[children.length - 1]));
}
return children;
}
Expand Down
12 changes: 6 additions & 6 deletions src/views/nodes/resultsCommitsNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ export interface CommitsQueryResults {
}

export class ResultsCommitsNode extends ViewNode<ViewWithFiles> implements PageableViewNode {
readonly supportsPaging: boolean = true;
maxCount: number | undefined;

// Generate a unique id so the node order is preserved, since we update the label when the query completes
private readonly _uniqueId: number = getNextId('ResultsCommitsNode');
readonly supportsPaging = true;
readonly rememberLastMaxCount = true;
maxCount: number | undefined = this.view.getNodeLastMaxCount(this);

constructor(
view: ViewWithFiles,
Expand Down Expand Up @@ -58,7 +56,9 @@ export class ResultsCommitsNode extends ViewNode<ViewWithFiles> implements Pagea
];

if (log.truncated) {
children.push(new ShowMoreNode(this.view, this, 'Results', children[children.length - 1], this.maxCount));
children.push(
new ShowMoreNode(this.view, this, 'Results', log.maxCount, children[children.length - 1], this.maxCount)
);
}

return children;
Expand Down
7 changes: 4 additions & 3 deletions src/views/nodes/tagNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import { getBranchesAndTagTipsFn, insertDateMarkers } from './helpers';
import { PageableViewNode, ResourceType, ViewNode, ViewRefNode } from './viewNode';

export class TagNode extends ViewRefNode<RepositoriesView> implements PageableViewNode {
readonly supportsPaging: boolean = true;
maxCount: number | undefined;
readonly supportsPaging = true;
readonly rememberLastMaxCount = true;
maxCount: number | undefined = this.view.getNodeLastMaxCount(this);

constructor(uri: GitUri, view: RepositoriesView, parent: ViewNode, public readonly tag: GitTag) {
super(uri, view, parent);
Expand Down Expand Up @@ -49,7 +50,7 @@ export class TagNode extends ViewRefNode<RepositoriesView> implements PageableVi
];

if (log.truncated) {
children.push(new ShowMoreNode(this.view, this, 'Commits', children[children.length - 1]));
children.push(new ShowMoreNode(this.view, this, 'Commits', log.maxCount, children[children.length - 1]));
}
return children;
}
Expand Down

0 comments on commit a402de3

Please sign in to comment.