Skip to content

Commit d4f53f3

Browse files
committed
Adds missing search context on focus change
1 parent d59a42a commit d4f53f3

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

src/webviews/plus/graph/graphWebview.ts

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -945,11 +945,23 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
945945
interaction: 'passive',
946946
preserveFocus: true,
947947
preserveVisibility: this._showDetailsView === false,
948+
searchContext: this.getSearchContext(activeSelection.ref),
948949
},
949950
{ source: this.host.id },
950951
);
951952
}
952953

954+
private getSearchContext(id: string | undefined): CommitSelectedEvent['data']['searchContext'] | undefined {
955+
if (!this._search?.queryFilters.files || id == null) return undefined;
956+
957+
const result = this._search.results.get(id);
958+
return {
959+
query: this._search.query,
960+
queryFilters: this._search.queryFilters,
961+
matchedFiles: result?.files ?? [],
962+
};
963+
}
964+
953965
private onConfigurationChanged(e: ConfigurationChangeEvent) {
954966
if (configuration.changed(e, 'graph.showDetailsView')) {
955967
this._showDetailsView = configuration.get('graph.showDetailsView');
@@ -1146,16 +1158,7 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
11461158

11471159
const commit = this.getRevisionReference(this.repository?.path, e.row.id, e.row.type);
11481160
if (commit != null) {
1149-
let searchContext: CommitSelectedEvent['data']['searchContext'] | undefined;
1150-
if (this._search?.queryFilters.files) {
1151-
const result = this._search.results.get(e.row.id);
1152-
searchContext = {
1153-
query: this._search.query,
1154-
queryFilters: this._search.queryFilters,
1155-
matchedFiles: result?.files ?? [],
1156-
};
1157-
}
1158-
1161+
const searchContext = this.getSearchContext(e.row.id);
11591162
this.container.events.fire(
11601163
'commit:selected',
11611164
{
@@ -1876,16 +1879,6 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
18761879
if (commits == null) return;
18771880
if (!this._firstSelection && this.host.is('editor') && !this.host.active) return;
18781881

1879-
let searchContext: CommitSelectedEvent['data']['searchContext'] | undefined;
1880-
if (this._search?.queryFilters.files && id != null) {
1881-
const result = this._search.results.get(id);
1882-
searchContext = {
1883-
query: this._search.query,
1884-
queryFilters: this._search.queryFilters,
1885-
matchedFiles: result?.files ?? [],
1886-
};
1887-
}
1888-
18891882
this.container.events.fire(
18901883
'commit:selected',
18911884
{
@@ -1895,7 +1888,7 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
18951888
preserveVisibility: this._firstSelection
18961889
? this._showDetailsView === false
18971890
: this._showDetailsView !== 'selection',
1898-
searchContext: searchContext,
1891+
searchContext: this.getSearchContext(id),
18991892
},
19001893
{ source: this.host.id },
19011894
);

0 commit comments

Comments
 (0)