瀏覽代碼

Gets more search results as needed when row paging

main
Eric Amodio 2 年之前
父節點
當前提交
d6fe77307d
共有 3 個檔案被更改,包括 27 行新增6 行删除
  1. +26
    -4
      src/plus/webviews/graph/graphWebview.ts
  2. +1
    -1
      src/plus/webviews/graph/protocol.ts
  3. +0
    -1
      src/webviews/apps/plus/graph/graph.tsx

+ 26
- 4
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;
}

+ 1
- 1
src/plus/webviews/graph/protocol.ts 查看文件

@ -96,7 +96,7 @@ export interface GetMoreCommitsParams {
export const GetMoreCommitsCommandType = new IpcCommandType<GetMoreCommitsParams>('graph/getMoreCommits');
export interface SearchCommitsParams {
search: SearchQuery;
search?: SearchQuery;
limit?: number;
more?: boolean;
}

+ 0
- 1
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 });
}

Loading…
取消
儲存