Skip to content

Commit 70bdf31

Browse files
authored
fix: AI search runs even when toggle is hidden (#255497)
* fix: AI search runs even when toggle is hidden * Also fix check for Ctrl+I keybinding
1 parent 2a0b416 commit 70bdf31

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ export class SettingsEditor2 extends EditorPane {
770770
}
771771

772772
toggleAiSearch(): void {
773-
if (this.showAiResultsAction) {
773+
if (this.searchInputActionBar && this.showAiResultsAction && this.searchInputActionBar.hasAction(this.showAiResultsAction)) {
774774
if (!this.showAiResultsAction.enabled) {
775775
aria.status(localize('noAiResults', "No AI results available at this time."));
776776
}
@@ -1820,23 +1820,27 @@ export class SettingsEditor2 extends EditorPane {
18201820
return;
18211821
}
18221822

1823-
// Kick off an AI search in the background. We purposely do not await it.
18241823
if (this.aiSearchPromise) {
18251824
this.aiSearchPromise.cancel();
18261825
}
1827-
this.aiSearchPromise = createCancelablePromise(token => {
1828-
return this.doAiSearch(query, token).then((results) => {
1829-
if (results && this.showAiResultsAction) {
1830-
this.showAiResultsAction.enabled = true;
1831-
this.showAiResultsAction.label = SHOW_AI_RESULTS_ENABLED_LABEL;
1832-
this.renderResultCountMessages(true);
1833-
}
1834-
}).catch(e => {
1835-
if (!isCancellationError(e)) {
1836-
this.logService.trace('Error during AI settings search:', e);
1837-
}
1826+
1827+
// Kick off an AI search in the background if the toggle is shown.
1828+
// We purposely do not await it.
1829+
if (this.searchInputActionBar && this.showAiResultsAction && this.searchInputActionBar.hasAction(this.showAiResultsAction)) {
1830+
this.aiSearchPromise = createCancelablePromise(token => {
1831+
return this.doAiSearch(query, token).then((results) => {
1832+
if (results && this.showAiResultsAction) {
1833+
this.showAiResultsAction.enabled = true;
1834+
this.showAiResultsAction.label = SHOW_AI_RESULTS_ENABLED_LABEL;
1835+
this.renderResultCountMessages(true);
1836+
}
1837+
}).catch(e => {
1838+
if (!isCancellationError(e)) {
1839+
this.logService.trace('Error during AI settings search:', e);
1840+
}
1841+
});
18381842
});
1839-
});
1843+
}
18401844

18411845
this.onDidFinishSearch(expandResults, progressRunner);
18421846
});

0 commit comments

Comments
 (0)