Преглед на файлове

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 });
}

Зареждане…
Отказ
Запис