diff --git a/src/plus/webviews/graph/graphWebview.ts b/src/plus/webviews/graph/graphWebview.ts index bcbca7a..3f040c5 100644 --- a/src/plus/webviews/graph/graphWebview.ts +++ b/src/plus/webviews/graph/graphWebview.ts @@ -20,7 +20,7 @@ import { gate } from '../../../system/decorators/gate'; import { debug } from '../../../system/decorators/log'; import type { Deferrable } from '../../../system/function'; import { debounce } from '../../../system/function'; -import { first } from '../../../system/iterable'; +import { first, last } from '../../../system/iterable'; import { updateRecordValue } from '../../../system/object'; import { isDarkTheme, isLightTheme } from '../../../system/utils'; import { RepositoryFolderNode } from '../../../views/nodes/viewNode'; @@ -430,6 +430,16 @@ export class GraphWebview extends WebviewBase { @debug() private async onSearchCommits(e: SearchCommitsParams, completionId?: string) { + if (e.search == null) { + this.resetSearchState(); + + // This shouldn't happen, but just in case + if (completionId != null) { + debugger; + } + return; + } + let search: GitSearch | undefined = this._search; if (e.more && search?.more != null && search.comparisonKey === getSearchQueryComparisonKey(e.search)) { @@ -747,12 +757,16 @@ export class GraphWebview extends WebviewBase { this.setSelectedRows(undefined); } + private resetSearchState() { + this._search = undefined; + this._searchCancellation?.dispose(); + this._searchCancellation = undefined; + } + private setGraph(graph: GitGraph | undefined) { this._graph = graph; if (graph == null) { - this._search = undefined; - this._searchCancellation?.dispose(); - this._searchCancellation = undefined; + this.resetSearchState(); } } @@ -761,6 +775,14 @@ export class GraphWebview extends WebviewBase { const updatedGraph = await graph.more?.(pageItemLimit ?? defaultItemLimit, sha); if (updatedGraph != null) { this.setGraph(updatedGraph); + + if (this._search != null) { + const search = this._search; + const lastResult = last(search.results); + if (lastResult != null && updatedGraph.ids.has(lastResult)) { + queueMicrotask(() => void this.onSearchCommits({ search: search.query, more: true })); + } + } } else { debugger; } diff --git a/src/plus/webviews/graph/protocol.ts b/src/plus/webviews/graph/protocol.ts index 8e15119..a1766bf 100644 --- a/src/plus/webviews/graph/protocol.ts +++ b/src/plus/webviews/graph/protocol.ts @@ -96,7 +96,7 @@ export interface GetMoreCommitsParams { export const GetMoreCommitsCommandType = new IpcCommandType('graph/getMoreCommits'); export interface SearchCommitsParams { - search: SearchQuery; + search?: SearchQuery; limit?: number; more?: boolean; } diff --git a/src/webviews/apps/plus/graph/graph.tsx b/src/webviews/apps/plus/graph/graph.tsx index 52bca26..795947d 100644 --- a/src/webviews/apps/plus/graph/graph.tsx +++ b/src/webviews/apps/plus/graph/graph.tsx @@ -302,7 +302,6 @@ export class GraphApp extends App { private onSearchCommits(search: SearchQuery | undefined, options?: { limit?: number }) { if (search == null) { this.state.searchResults = undefined; - return; } return this.sendCommand(SearchCommitsCommandType, { search: search, limit: options?.limit }); }