diff --git a/src/env/node/git/localGitProvider.ts b/src/env/node/git/localGitProvider.ts index 80d3db2..89e7808 100644 --- a/src/env/node/git/localGitProvider.ts +++ b/src/env/node/git/localGitProvider.ts @@ -1656,26 +1656,20 @@ export class LocalGitProvider implements GitProvider, Disposable { async function getCommitsForGraphCore( this: LocalGitProvider, limit: number, - shaOrCursor?: string | { sha: string; skip: number }, + sha?: string, + cursor?: { sha: string; skip: number }, ): Promise { iterations++; - let cursor: { sha: string; skip: number } | undefined; - let sha: string | undefined; - if (shaOrCursor != null) { - if (typeof shaOrCursor === 'string') { - sha = shaOrCursor; - } else { - cursor = shaOrCursor; - } - } - let log: string | string[] | undefined; let nextPageLimit = limit; let size; do { const args = [...parser.arguments, `--${ordering}-order`, '--all']; + if (cursor?.skip) { + args.push(`--skip=${cursor.skip}`); + } let data; if (sha) { @@ -1688,9 +1682,6 @@ export class LocalGitProvider implements GitProvider, Disposable { ); } else { args.push(`-n${nextPageLimit + 1}`); - if (cursor?.skip) { - args.push(`--skip=${cursor.skip}`); - } data = await this.git.log2(repoPath, stdin ? { stdin: stdin } : undefined, ...args); @@ -1870,8 +1861,8 @@ export class LocalGitProvider implements GitProvider, Disposable { startingCursor: startingCursor, more: count > limit, }, - more: async (limit: number): Promise => - getCommitsForGraphCore.call(this, limit, cursor), + more: async (limit: number, sha?: string): Promise => + getCommitsForGraphCore.call(this, limit, sha, cursor), }; } diff --git a/src/plus/webviews/graph/graphWebview.ts b/src/plus/webviews/graph/graphWebview.ts index b8411b7..94ea9e3 100644 --- a/src/plus/webviews/graph/graphWebview.ts +++ b/src/plus/webviews/graph/graphWebview.ts @@ -128,7 +128,8 @@ export class GraphWebview extends WebviewBase { return; } - this.updateState(); + this.setSelectedRows(args.sha); + void this.onGetMoreCommits(args.sha); } }), ); @@ -193,7 +194,7 @@ export class GraphWebview extends WebviewBase { onIpc(GetMissingAvatarsCommandType, e, params => this.onGetMissingAvatars(params.emails)); break; case GetMoreCommitsCommandType.method: - onIpc(GetMoreCommitsCommandType, e, () => this.onGetMoreCommits()); + onIpc(GetMoreCommitsCommandType, e, params => this.onGetMoreCommits(params.sha)); break; case UpdateColumnCommandType.method: onIpc(UpdateColumnCommandType, e, params => this.onColumnUpdated(params.name, params.config)); @@ -362,7 +363,7 @@ export class GraphWebview extends WebviewBase { } @gate() - private async onGetMoreCommits() { + private async onGetMoreCommits(sha?: string) { if (this._graph?.more == null || this._repository?.etag !== this._etagRepository) { this.updateState(true); @@ -370,7 +371,7 @@ export class GraphWebview extends WebviewBase { } const { defaultItemLimit, pageItemLimit } = configuration.get('graph'); - const newGraph = await this._graph.more(pageItemLimit ?? defaultItemLimit); + const newGraph = await this._graph.more(pageItemLimit ?? defaultItemLimit, sha); if (newGraph != null) { this.setGraph(newGraph); } else { @@ -505,6 +506,7 @@ export class GraphWebview extends WebviewBase { success = await this.notify(DidChangeCommitsNotificationType, { rows: data.rows, avatars: Object.fromEntries(data.avatars), + selectedRows: this._selectedRows, paging: { startingCursor: data.paging?.startingCursor, more: data.paging?.more ?? false, diff --git a/src/plus/webviews/graph/protocol.ts b/src/plus/webviews/graph/protocol.ts index 391eed5..b43c120 100644 --- a/src/plus/webviews/graph/protocol.ts +++ b/src/plus/webviews/graph/protocol.ts @@ -82,7 +82,10 @@ export interface GetMissingAvatarsParams { } export const GetMissingAvatarsCommandType = new IpcCommandType('graph/getMissingAvatars'); -export const GetMoreCommitsCommandType = new IpcCommandType('graph/getMoreCommits'); +export interface GetMoreCommitsParams { + sha?: string; +} +export const GetMoreCommitsCommandType = new IpcCommandType('graph/getMoreCommits'); export interface UpdateColumnParams { name: string; @@ -133,6 +136,7 @@ export const DidChangeAvatarsNotificationType = new IpcNotificationType( diff --git a/src/webviews/apps/plus/graph/graph.tsx b/src/webviews/apps/plus/graph/graph.tsx index c7b80a6..4f7fccc 100644 --- a/src/webviews/apps/plus/graph/graph.tsx +++ b/src/webviews/apps/plus/graph/graph.tsx @@ -174,9 +174,10 @@ export class GraphApp extends App { this.setState({ ...this.state, avatars: params.avatars, + paging: params.paging, + selectedRows: params.selectedRows, rows: rows, loading: false, - paging: params.paging, }); this.refresh(this.state); }); @@ -273,8 +274,8 @@ export class GraphApp extends App { this.sendCommand(GetMissingAvatarsCommandType, { emails: emails }); } - private onGetMoreCommits() { - this.sendCommand(GetMoreCommitsCommandType, undefined); + private onGetMoreCommits(sha?: string) { + this.sendCommand(GetMoreCommitsCommandType, { sha: sha }); } private onSelectionChanged(selection: { id: string; type: GitGraphRowType }[]) {