diff --git a/src/env/node/git/localGitProvider.ts b/src/env/node/git/localGitProvider.ts index ed6b804..e221430 100644 --- a/src/env/node/git/localGitProvider.ts +++ b/src/env/node/git/localGitProvider.ts @@ -1838,12 +1838,12 @@ export class LocalGitProvider implements GitProvider, Disposable { }); } - const last = rows[rows.length - 1]; const startingCursor = cursor?.sha; + const lastSha = last(ids); cursor = - last != null + lastSha != null ? { - sha: last.sha, + sha: lastSha, skip: total - iterations, } : undefined; @@ -1858,7 +1858,7 @@ export class LocalGitProvider implements GitProvider, Disposable { paging: { limit: limit === 0 ? count : limit, startingCursor: startingCursor, - hasMore: count > limit, + hasMore: limit !== 0 && count > limit, }, more: async (limit: number, sha?: string): Promise => getCommitsForGraphCore.call(this, limit, sha, cursor), diff --git a/src/webviews/apps/plus/graph/GraphWrapper.tsx b/src/webviews/apps/plus/graph/GraphWrapper.tsx index cdf24a9..1700bc9 100644 --- a/src/webviews/apps/plus/graph/GraphWrapper.tsx +++ b/src/webviews/apps/plus/graph/GraphWrapper.tsx @@ -43,10 +43,10 @@ export interface GraphWrapperProps extends State { onSearchCommitsPromise?: ( search: SearchQuery, options?: { limit?: number; more?: boolean }, - ) => Promise; + ) => Promise; onDismissBanner?: (key: DismissBannerParams['key']) => void; onSelectionChange?: (selection: { id: string; type: GitGraphRowType }[]) => void; - onEnsureCommitPromise?: (id: string, select: boolean) => Promise; + onEnsureCommitPromise?: (id: string, select: boolean) => Promise; } const getStyleProps = ( diff --git a/src/webviews/apps/plus/graph/graph.tsx b/src/webviews/apps/plus/graph/graph.tsx index 795947d..7ee633f 100644 --- a/src/webviews/apps/plus/graph/graph.tsx +++ b/src/webviews/apps/plus/graph/graph.tsx @@ -119,7 +119,7 @@ export class GraphApp extends App { case DidChangeCommitsNotificationType.method: onIpc(DidChangeCommitsNotificationType, msg, params => { let rows; - if (params?.paging?.startingCursor != null && this.state.rows != null) { + if (params.rows.length && params.paging?.startingCursor != null && this.state.rows != null) { const previousRows = this.state.rows; const lastSha = previousRows[previousRows.length - 1]?.sha; @@ -306,20 +306,28 @@ export class GraphApp extends App { return this.sendCommand(SearchCommitsCommandType, { search: search, limit: options?.limit }); } - private onSearchCommitsPromise(search: SearchQuery, options?: { limit?: number; more?: boolean }) { - return this.sendCommandWithCompletion( - SearchCommitsCommandType, - { search: search, limit: options?.limit, more: options?.more }, - DidSearchCommitsNotificationType, - ); + private async onSearchCommitsPromise(search: SearchQuery, options?: { limit?: number; more?: boolean }) { + try { + return await this.sendCommandWithCompletion( + SearchCommitsCommandType, + { search: search, limit: options?.limit, more: options?.more }, + DidSearchCommitsNotificationType, + ); + } catch { + return undefined; + } } - private onEnsureCommitPromise(id: string, select: boolean) { - return this.sendCommandWithCompletion( - EnsureCommitCommandType, - { id: id, select: select }, - DidEnsureCommitNotificationType, - ); + private async onEnsureCommitPromise(id: string, select: boolean) { + try { + return await this.sendCommandWithCompletion( + EnsureCommitCommandType, + { id: id, select: select }, + DidEnsureCommitNotificationType, + ); + } catch { + return undefined; + } } private onSelectionChanged(selection: { id: string; type: GitGraphRowType }[]) {