From d1c1e2702857fec3f73132b89db0c2f8e40c858a Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Mon, 2 Mar 2020 04:35:43 -0500 Subject: [PATCH] =?UTF-8?q?Changes=20limit=20to=20take=20a=20cursor=20obje?= =?UTF-8?q?ct=20=E2=80=94=20#91722?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/git/src/timelineProvider.ts | 4 ++-- src/vs/vscode.proposed.d.ts | 2 +- .../contrib/timeline/browser/timelinePane.ts | 14 ++++++++++---- .../workbench/contrib/timeline/common/timeline.ts | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/extensions/git/src/timelineProvider.ts b/extensions/git/src/timelineProvider.ts index c177f8bfcc0..872e5c36a80 100644 --- a/extensions/git/src/timelineProvider.ts +++ b/extensions/git/src/timelineProvider.ts @@ -114,9 +114,9 @@ export class GitTimelineProvider implements TimelineProvider { // TODO[ECA]: Ensure that the uri is a file -- if not we could get the history of the repo? let limit: number | undefined; - if (typeof options.limit === 'string') { + if (options.limit !== undefined && typeof options.limit !== 'number') { try { - const result = await this._model.git.exec(repo.root, ['rev-list', '--count', `${options.limit}..`, '--', uri.fsPath]); + const result = await this._model.git.exec(repo.root, ['rev-list', '--count', `${options.limit.cursor}..`, '--', uri.fsPath]); if (!result.exitCode) { // Ask for 1 more than so we can determine if there are more commits limit = Number(result.stdout) + 1; diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index d1ccd81b83f..7e66d226c50 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -1600,7 +1600,7 @@ declare module 'vscode' { /** * The maximum number or the ending cursor of timeline items that should be returned. */ - limit?: number | string; + limit?: number | { cursor: string }; } export interface TimelineProvider { diff --git a/src/vs/workbench/contrib/timeline/browser/timelinePane.ts b/src/vs/workbench/contrib/timeline/browser/timelinePane.ts index 031b6f27d11..976f6d73937 100644 --- a/src/vs/workbench/contrib/timeline/browser/timelinePane.ts +++ b/src/vs/workbench/contrib/timeline/browser/timelinePane.ts @@ -80,8 +80,8 @@ interface TimelineActionContext { } interface TimelineCursors { - startCursors?: { before: any; after?: any }; - endCursors?: { before: any; after?: any }; + startCursors?: { before: string; after?: string }; + endCursors?: { before: string; after?: string }; more: boolean; } @@ -308,7 +308,9 @@ export class TimelinePane extends ViewPane { { cursor: options.before ? cursors?.startCursors?.before : (cursors?.endCursors ?? cursors?.startCursors)?.after, ...options, - limit: options.limit === 0 ? undefined : options.limit ?? defaultPageSize + limit: options.limit === 0 + ? undefined + : options.limit ?? defaultPageSize }, request?.tokenSource ?? new CancellationTokenSource(), { cacheResults: true, resetCache: false } )!; @@ -329,7 +331,11 @@ export class TimelinePane extends ViewPane { source, this._uri, { ...options, - limit: options.limit === 0 ? undefined : (reset ? cursors?.endCursors?.after : undefined) ?? options.limit ?? defaultPageSize + limit: options.limit === 0 + ? undefined + : (reset && cursors?.endCursors?.after !== undefined + ? { cursor: cursors.endCursors.after } + : undefined) ?? options.limit ?? defaultPageSize }, new CancellationTokenSource(), { cacheResults: true, resetCache: true } )!; diff --git a/src/vs/workbench/contrib/timeline/common/timeline.ts b/src/vs/workbench/contrib/timeline/common/timeline.ts index 72ca602fa56..3f7cad3109e 100644 --- a/src/vs/workbench/contrib/timeline/common/timeline.ts +++ b/src/vs/workbench/contrib/timeline/common/timeline.ts @@ -40,7 +40,7 @@ export interface TimelineChangeEvent { export interface TimelineOptions { cursor?: string; before?: boolean; - limit?: number | string; + limit?: number | { cursor: string }; } export interface InternalTimelineOptions { -- GitLab