소스 검색

Re-adds saving of last limit on "soft" refreshes

main
Eric Amodio 5 년 전
부모
커밋
14defd7bab
12개의 변경된 파일72개의 추가작업 그리고 10개의 파일을 삭제
  1. +3
    -1
      src/views/nodes/branchNode.ts
  2. +3
    -1
      src/views/nodes/branchTrackingStatusNode.ts
  3. +3
    -1
      src/views/nodes/contributorNode.ts
  4. +13
    -1
      src/views/nodes/fileHistoryNode.ts
  5. +13
    -1
      src/views/nodes/lineHistoryNode.ts
  6. +3
    -1
      src/views/nodes/reflogNode.ts
  7. +3
    -1
      src/views/nodes/reflogRecordNode.ts
  8. +3
    -1
      src/views/nodes/resultsCommitsNode.ts
  9. +3
    -1
      src/views/nodes/tagNode.ts
  10. +2
    -0
      src/views/nodes/viewNode.ts
  11. +17
    -1
      src/views/viewBase.ts
  12. +6
    -0
      src/views/viewCommands.ts

+ 3
- 1
src/views/nodes/branchNode.ts 파일 보기

@ -234,7 +234,7 @@ export class BranchNode extends ViewRefNode implements Pageabl
private async getLog() {
if (this._log === undefined) {
this._log = await Container.git.getLog(this.uri.repoPath!, {
limit: this.view.config.defaultItemLimit,
limit: this.limit ?? this.view.config.defaultItemLimit,
ref: this.ref
});
}
@ -246,6 +246,7 @@ export class BranchNode extends ViewRefNode implements Pageabl
return this._log?.hasMore ?? true;
}
limit: number | undefined = this.view.getNodeLastKnownLimit(this);
async showMore(limit?: number | { until?: any }) {
let log = await this.getLog();
if (log === undefined || !log.hasMore) return;
@ -254,6 +255,7 @@ export class BranchNode extends ViewRefNode implements Pageabl
if (this._log === log) return;
this._log = log;
this.limit = log?.count;
this.triggerChange(false);
}
}

+ 3
- 1
src/views/nodes/branchTrackingStatusNode.ts 파일 보기

@ -137,7 +137,7 @@ export class BranchTrackingStatusNode extends ViewNode implements
: `${this.status.ref}..${this.status.upstream}`;
this._log = await Container.git.getLog(this.uri.repoPath!, {
limit: this.view.config.defaultItemLimit,
limit: this.limit ?? this.view.config.defaultItemLimit,
ref: range
});
}
@ -149,6 +149,7 @@ export class BranchTrackingStatusNode extends ViewNode implements
return this._log?.hasMore ?? true;
}
limit: number | undefined = this.view.getNodeLastKnownLimit(this);
async showMore(limit?: number | { until?: any }) {
let log = await this.getLog();
if (log === undefined || !log.hasMore) return;
@ -157,6 +158,7 @@ export class BranchTrackingStatusNode extends ViewNode implements
if (this._log === log) return;
this._log = log;
this.limit = log?.count;
this.triggerChange(false);
}
}

+ 3
- 1
src/views/nodes/contributorNode.ts 파일 보기

@ -84,7 +84,7 @@ export class ContributorNode extends ViewNode implements Pagea
private async getLog() {
if (this._log === undefined) {
this._log = await Container.git.getLog(this.uri.repoPath!, {
limit: this.view.config.defaultItemLimit,
limit: this.limit ?? this.view.config.defaultItemLimit,
authors: [`^${this.contributor.name} <${this.contributor.email}>$`]
});
}
@ -96,6 +96,7 @@ export class ContributorNode extends ViewNode implements Pagea
return this._log?.hasMore ?? true;
}
limit: number | undefined = this.view.getNodeLastKnownLimit(this);
async showMore(limit?: number | { until?: any }) {
let log = await this.getLog();
if (log === undefined || !log.hasMore) return;
@ -104,6 +105,7 @@ export class ContributorNode extends ViewNode implements Pagea
if (this._log === log) return;
this._log = log;
this.limit = log?.count;
this.triggerChange(false);
}
}

+ 13
- 1
src/views/nodes/fileHistoryNode.ts 파일 보기

@ -18,8 +18,14 @@ import { CommitFileNode } from './commitFileNode';
import { MessageNode, ShowMoreNode } from './common';
import { insertDateMarkers } from './helpers';
import { PageableViewNode, ResourceType, SubscribeableViewNode, ViewNode } from './viewNode';
import { RepositoryNode } from './repositoryNode';
export class FileHistoryNode extends SubscribeableViewNode implements PageableViewNode {
static key = ':history:file';
static getId(repoPath: string, uri: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}(${uri})`;
}
constructor(uri: GitUri, view: View, parent: ViewNode) {
super(uri, view, parent);
}
@ -28,6 +34,10 @@ export class FileHistoryNode extends SubscribeableViewNode implements PageableVi
return this.uri.fileName;
}
get id(): string {
return FileHistoryNode.getId(this.uri.repoPath!, this.uri.toString(true));
}
async getChildren(): Promise<ViewNode[]> {
const children: ViewNode[] = [];
@ -171,7 +181,7 @@ export class FileHistoryNode extends SubscribeableViewNode implements PageableVi
private async getLog() {
if (this._log === undefined) {
this._log = await Container.git.getLogForFile(this.uri.repoPath, this.uri.fsPath, {
limit: this.view.config.defaultItemLimit,
limit: this.limit ?? this.view.config.defaultItemLimit,
ref: this.uri.sha
});
}
@ -183,6 +193,7 @@ export class FileHistoryNode extends SubscribeableViewNode implements PageableVi
return this._log?.hasMore ?? true;
}
limit: number | undefined = this.view.getNodeLastKnownLimit(this);
async showMore(limit?: number | { until?: any }) {
let log = await this.getLog();
if (log === undefined || !log.hasMore) return;
@ -191,6 +202,7 @@ export class FileHistoryNode extends SubscribeableViewNode implements PageableVi
if (this._log === log) return;
this._log = log;
this.limit = log?.count;
this.triggerChange(false);
}
}

+ 13
- 1
src/views/nodes/lineHistoryNode.ts 파일 보기

@ -17,8 +17,14 @@ import { CommitFileNode } from './commitFileNode';
import { MessageNode, ShowMoreNode } from './common';
import { insertDateMarkers } from './helpers';
import { PageableViewNode, ResourceType, SubscribeableViewNode, ViewNode } from './viewNode';
import { RepositoryNode } from './repositoryNode';
export class LineHistoryNode extends SubscribeableViewNode implements PageableViewNode {
static key = ':history:line';
static getId(repoPath: string, uri: string, selection: Selection): string {
return `${RepositoryNode.getId(repoPath)}${this.key}(${uri}[${selection.start.line},${selection.start.character}-${selection.end.line},${selection.end.character}])`;
}
constructor(
uri: GitUri,
view: View,
@ -33,6 +39,10 @@ export class LineHistoryNode extends SubscribeableViewNode implements PageableVi
return this.uri.fileName;
}
get id(): string {
return LineHistoryNode.getId(this.uri.repoPath!, this.uri.toString(true), this.selection);
}
async getChildren(): Promise<ViewNode[]> {
const children: ViewNode[] = [];
@ -202,7 +212,7 @@ export class LineHistoryNode extends SubscribeableViewNode implements PageableVi
private async getLog(selection?: Selection) {
if (this._log === undefined) {
this._log = await Container.git.getLogForFile(this.uri.repoPath, this.uri.fsPath, {
limit: this.view.config.defaultItemLimit,
limit: this.limit ?? this.view.config.defaultItemLimit,
ref: this.uri.sha,
range: selection ?? this.selection
});
@ -215,6 +225,7 @@ export class LineHistoryNode extends SubscribeableViewNode implements PageableVi
return this._log?.hasMore ?? true;
}
limit: number | undefined = this.view.getNodeLastKnownLimit(this);
async showMore(limit?: number | { until?: any }) {
let log = await this.getLog();
if (log === undefined || !log.hasMore) return;
@ -223,6 +234,7 @@ export class LineHistoryNode extends SubscribeableViewNode implements PageableVi
if (this._log === log) return;
this._log = log;
this.limit = log?.count;
this.triggerChange(false);
}
}

+ 3
- 1
src/views/nodes/reflogNode.ts 파일 보기

@ -74,7 +74,7 @@ export class ReflogNode extends ViewNode implements PageableVi
if (this._reflog === undefined) {
this._reflog = await Container.git.getIncomingActivity(this.repo.path, {
all: true,
limit: this.view.config.defaultItemLimit
limit: this.limit ?? this.view.config.defaultItemLimit
});
}
@ -85,6 +85,7 @@ export class ReflogNode extends ViewNode implements PageableVi
return this._reflog?.hasMore ?? true;
}
limit: number | undefined = this.view.getNodeLastKnownLimit(this);
async showMore(limit?: number) {
let reflog = await this.getReflog();
if (reflog === undefined || !reflog.hasMore) return;
@ -93,6 +94,7 @@ export class ReflogNode extends ViewNode implements PageableVi
if (this._reflog === reflog) return;
this._reflog = reflog;
this.limit = reflog?.count;
this.triggerChange(false);
}
}

+ 3
- 1
src/views/nodes/reflogRecordNode.ts 파일 보기

@ -89,7 +89,7 @@ export class ReflogRecordNode extends ViewNode implements Pageabl
if (this._log === undefined) {
const range = `${this.record.previousSha}..${this.record.sha}`;
this._log = await Container.git.getLog(this.uri.repoPath!, {
limit: this.view.config.defaultItemLimit,
limit: this.limit ?? this.view.config.defaultItemLimit,
ref: range
});
}
@ -101,6 +101,7 @@ export class ReflogRecordNode extends ViewNode implements Pageabl
return this._log?.hasMore ?? true;
}
limit: number | undefined = this.view.getNodeLastKnownLimit(this);
async showMore(limit?: number | { until?: any }) {
let log = await this.getLog();
if (log === undefined || !log.hasMore) return;
@ -109,6 +110,7 @@ export class ReflogRecordNode extends ViewNode implements Pageabl
if (this._log === log) return;
this._log = log;
this.limit = log?.count;
this.triggerChange(false);
}
}

+ 3
- 1
src/views/nodes/resultsCommitsNode.ts 파일 보기

@ -114,7 +114,7 @@ export class ResultsCommitsNode extends ViewNode implements Pagea
private _commitsQueryResults: Promise<CommitsQueryResults> | undefined;
private async getCommitsQueryResults() {
if (this._commitsQueryResults === undefined) {
this._commitsQueryResults = this._commitsQuery(Container.config.advanced.maxSearchItems);
this._commitsQueryResults = this._commitsQuery(this.limit ?? Container.config.advanced.maxSearchItems);
const results = await this._commitsQueryResults;
this._hasMore = results.hasMore;
}
@ -127,12 +127,14 @@ export class ResultsCommitsNode extends ViewNode implements Pagea
return this._hasMore;
}
limit: number | undefined = this.view.getNodeLastKnownLimit(this);
async showMore(limit?: number) {
const results = await this.getCommitsQueryResults();
if (results === undefined || !results.hasMore) return;
await results.more?.(limit ?? this.view.config.pageItemLimit);
this.limit = results.log?.count;
this.triggerChange(false);
}
}

+ 3
- 1
src/views/nodes/tagNode.ts 파일 보기

@ -94,7 +94,7 @@ export class TagNode extends ViewRefNode implements PageableVi
private async getLog() {
if (this._log === undefined) {
this._log = await Container.git.getLog(this.uri.repoPath!, {
limit: this.view.config.defaultItemLimit,
limit: this.limit ?? this.view.config.defaultItemLimit,
ref: this.tag.name
});
}
@ -106,6 +106,7 @@ export class TagNode extends ViewRefNode implements PageableVi
return this._log?.hasMore ?? true;
}
limit: number | undefined = this.view.getNodeLastKnownLimit(this);
async showMore(limit?: number | { until?: any }) {
let log = await this.getLog();
if (log === undefined || !log.hasMore) return;
@ -114,6 +115,7 @@ export class TagNode extends ViewRefNode implements PageableVi
if (this._log === log) return;
this._log = log;
this.limit = log?.count;
this.triggerChange(false);
}
}

+ 2
- 0
src/views/nodes/viewNode.ts 파일 보기

@ -118,6 +118,8 @@ export function nodeSupportsConditionalDismissal(node: ViewNode): node is ViewNo
}
export interface PageableViewNode {
readonly id: string;
limit?: number;
readonly hasMore: boolean;
showMore(limit?: number | { until?: any }): Promise<void>;
}

+ 17
- 1
src/views/viewBase.ts 파일 보기

@ -51,6 +51,7 @@ export abstract class ViewBase> implements TreeData
}
protected _disposable: Disposable | undefined;
private readonly _lastKnownLimits = new Map<string, number | undefined>();
protected _root: TRoot | undefined;
protected _tree: TreeView<ViewNode> | undefined;
@ -372,6 +373,20 @@ export abstract class ViewBase> implements TreeData
}
@debug({
args: { 0: (n: ViewNode) => n.toString() }
})
getNodeLastKnownLimit(node: PageableViewNode) {
return this._lastKnownLimits.get(node.id);
}
@debug({
args: { 0: (n: ViewNode) => n.toString() }
})
resetNodeLastKnownLimit(node: PageableViewNode) {
this._lastKnownLimits.delete(node.id);
}
@debug({
args: {
0: (n: ViewNode & PageableViewNode) => n.toString(),
3: (n?: ViewNode) => (n === undefined ? '' : n.toString())
@ -386,7 +401,8 @@ export abstract class ViewBase> implements TreeData
void (await this.reveal(previousNode, { select: true }));
}
return node.showMore(limit);
await node.showMore(limit);
this._lastKnownLimits.set(node.id, node.limit);
}
@debug({

+ 6
- 0
src/views/viewCommands.ts 파일 보기

@ -26,6 +26,7 @@ import {
FileHistoryNode,
FolderNode,
LineHistoryNode,
PageableViewNode,
PagerNode,
RemoteNode,
RepositoryNode,
@ -67,6 +68,11 @@ export class ViewCommands {
commands.registerCommand(
'gitlens.views.refreshNode',
(node: ViewNode, reset?: boolean) => {
if (reset == null && PageableViewNode.is(node)) {
node.limit = undefined;
node.view.resetNodeLastKnownLimit(node);
}
return node.view.refreshNode(node, reset == null ? true : reset);
},
this

불러오는 중...
취소
저장