@codingame/monaco-vscode-search-service-override 3.2.2 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,5 @@
1
+ export { AbstractDialogHandler, IDialogService, IFileDialogService, getFileNamesMessage } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
2
+
1
3
  var ConfirmResult;
2
4
  ( (function(ConfirmResult) {
3
5
  ConfirmResult[ConfirmResult["SAVE"] = 0] = "SAVE";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-search-service-override",
3
- "version": "3.2.2",
3
+ "version": "4.0.0",
4
4
  "keywords": [],
5
5
  "author": {
6
6
  "name": "CodinGame",
@@ -18,6 +18,6 @@
18
18
  "module": "index.js",
19
19
  "types": "index.d.ts",
20
20
  "dependencies": {
21
- "vscode": "npm:@codingame/monaco-vscode-api@3.2.2"
21
+ "vscode": "npm:@codingame/monaco-vscode-api@4.0.0"
22
22
  }
23
23
  }
@@ -14,7 +14,7 @@ import { URI } from 'vscode/vscode/vs/base/common/uri';
14
14
  import { toLocalResource, basenameOrAuthority, dirname } from 'vscode/vscode/vs/base/common/resources';
15
15
  import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService';
16
16
  import { IFileService } from 'vscode/vscode/vs/platform/files/common/files';
17
- import { DisposableStore, MutableDisposable, Disposable, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
17
+ import { Disposable, DisposableStore, MutableDisposable, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
18
18
  import { ILabelService } from 'vscode/vscode/vs/platform/label/common/label';
19
19
  import { getIconClasses } from 'vscode/vscode/vs/editor/common/services/getIconClasses';
20
20
  import { IModelService } from 'vscode/vscode/vs/editor/common/services/model';
@@ -34,7 +34,7 @@ import { IFilesConfigurationService } from 'vscode/vscode/vs/workbench/services/
34
34
  import { ResourceMap } from 'vscode/vscode/vs/base/common/map';
35
35
  import { SymbolsQuickAccessProvider } from './symbolsQuickAccess.js';
36
36
  import { DefaultQuickAccessFilterValue, Extensions } from 'vscode/vscode/vs/platform/quickinput/common/quickAccess';
37
- import { EditorViewState } from 'vscode/vscode/vs/workbench/browser/quickaccess';
37
+ import { PickerEditorState } from 'vscode/vscode/vs/workbench/browser/quickaccess';
38
38
  import { GotoSymbolQuickAccessProvider } from 'vscode/vscode/vs/workbench/contrib/codeEditor/browser/quickaccess/gotoSymbolQuickAccess';
39
39
  import { ITextModelService } from 'vscode/vscode/vs/editor/common/services/resolverService';
40
40
  import { Event } from 'vscode/vscode/vs/base/common/event';
@@ -47,6 +47,7 @@ import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/
47
47
  import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
48
48
  import { ASK_QUICK_QUESTION_ACTION_ID } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions';
49
49
  import { IQuickChatService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat';
50
+ import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
50
51
 
51
52
  var AnythingQuickAccessProvider_1;
52
53
  function isEditorSymbolQuickPickItem(pick) {
@@ -72,7 +73,7 @@ let AnythingQuickAccessProvider = class AnythingQuickAccessProvider extends Pick
72
73
  }
73
74
  return undefined;
74
75
  }
75
- constructor(instantiationService, searchService, contextService, pathService, environmentService, fileService, labelService, modelService, languageService, workingCopyService, configurationService, editorService, historyService, filesConfigurationService, textModelService, uriIdentityService, quickInputService, keybindingService, quickChatService) {
76
+ constructor(instantiationService, searchService, contextService, pathService, environmentService, fileService, labelService, modelService, languageService, workingCopyService, configurationService, editorService, historyService, filesConfigurationService, textModelService, uriIdentityService, quickInputService, keybindingService, quickChatService, logService) {
76
77
  super(AnythingQuickAccessProvider_1.PREFIX, {
77
78
  canAcceptInBackground: true,
78
79
  noResultsPick: AnythingQuickAccessProvider_1.NO_RESULTS_PICK
@@ -96,10 +97,14 @@ let AnythingQuickAccessProvider = class AnythingQuickAccessProvider extends Pick
96
97
  this.quickInputService = quickInputService;
97
98
  this.keybindingService = keybindingService;
98
99
  this.quickChatService = quickChatService;
99
- this.pickState = new (class {
100
- constructor(provider, editorService) {
100
+ this.logService = logService;
101
+ this.pickState = this._register(new (class extends Disposable {
102
+ constructor(provider, instantiationService) {
103
+ super();
101
104
  this.provider = provider;
105
+ this.instantiationService = instantiationService;
102
106
  this.picker = undefined;
107
+ this.editorViewState = this._register(this.instantiationService.createInstance(PickerEditorState));
103
108
  this.scorerCache = Object.create(null);
104
109
  this.fileQueryCache = undefined;
105
110
  this.lastOriginalFilter = undefined;
@@ -107,7 +112,6 @@ let AnythingQuickAccessProvider = class AnythingQuickAccessProvider extends Pick
107
112
  this.lastRange = undefined;
108
113
  this.lastGlobalPicks = undefined;
109
114
  this.isQuickNavigating = undefined;
110
- this.editorViewState = ( new EditorViewState(editorService));
111
115
  }
112
116
  set(picker) {
113
117
  this.picker = picker;
@@ -128,7 +132,7 @@ let AnythingQuickAccessProvider = class AnythingQuickAccessProvider extends Pick
128
132
  this.lastGlobalPicks = undefined;
129
133
  this.editorViewState.reset();
130
134
  }
131
- })(this, this.editorService);
135
+ })(this, this.instantiationService));
132
136
  this.labelOnlyEditorHistoryPickAccessor = ( new QuickPickItemScorerAccessor({ skipDescription: true }));
133
137
  this.fileQueryDelayer = this._register(( new ThrottledDelayer(AnythingQuickAccessProvider_1.TYPING_SEARCH_DELAY)));
134
138
  this.fileQueryBuilder = this.instantiationService.createInstance(QueryBuilder);
@@ -210,7 +214,10 @@ let AnythingQuickAccessProvider = class AnythingQuickAccessProvider extends Pick
210
214
  };
211
215
  }
212
216
  }
213
- return this.doGetPicks(filter, { enableEditorSymbolSearch: lastWasFiltering, includeHelp: runOptions?.includeHelp, from: runOptions?.from }, disposables, token);
217
+ return this.doGetPicks(filter, {
218
+ ...runOptions,
219
+ enableEditorSymbolSearch: lastWasFiltering
220
+ }, disposables, token);
214
221
  }
215
222
  doGetPicks(filter, options, disposables, token) {
216
223
  const query = prepareQuery(filter);
@@ -225,12 +232,21 @@ let AnythingQuickAccessProvider = class AnythingQuickAccessProvider extends Pick
225
232
  return this.pickState.lastGlobalPicks;
226
233
  }
227
234
  const historyEditorPicks = this.getEditorHistoryPicks(query);
228
- let picks;
235
+ let picks = ( new Array());
236
+ if (options.additionPicks) {
237
+ picks.push(...options.additionPicks);
238
+ }
229
239
  if (this.pickState.isQuickNavigating) {
240
+ if (picks.length > 0) {
241
+ picks.push({ type: 'separator', label: ( localizeWithPath(
242
+ 'vs/workbench/contrib/search/browser/anythingQuickAccess',
243
+ 'recentlyOpenedSeparator',
244
+ "recently opened"
245
+ )) });
246
+ }
230
247
  picks = historyEditorPicks;
231
248
  }
232
249
  else {
233
- picks = [];
234
250
  if (options.includeHelp) {
235
251
  picks.push(...this.getHelpPicks(query, token, options));
236
252
  }
@@ -428,11 +444,14 @@ let AnythingQuickAccessProvider = class AnythingQuickAccessProvider extends Pick
428
444
  return ( fileSearchResults.results.map(result => result.resource));
429
445
  }
430
446
  doGetFileSearchResults(filePattern, token) {
447
+ const start = Date.now();
431
448
  return this.searchService.fileSearch(this.fileQueryBuilder.file(this.contextService.getWorkspace().folders, this.getFileQueryOptions({
432
449
  filePattern,
433
450
  cacheKey: this.pickState.fileQueryCache?.cacheKey,
434
451
  maxResults: AnythingQuickAccessProvider_1.MAX_RESULTS
435
- })), token);
452
+ })), token).finally(() => {
453
+ this.logService.trace(`QuickAccess fileSearch ${Date.now() - start}ms`);
454
+ });
436
455
  }
437
456
  getFileQueryOptions(input) {
438
457
  return {
@@ -582,7 +601,7 @@ let AnythingQuickAccessProvider = class AnythingQuickAccessProvider extends Pick
582
601
  async doGetEditorSymbolPicks(activeGlobalPick, activeGlobalResource, filter, disposables, token) {
583
602
  try {
584
603
  this.pickState.editorViewState.set();
585
- await this.editorService.openEditor({
604
+ await this.pickState.editorViewState.openTransientEditor({
586
605
  resource: activeGlobalResource,
587
606
  options: { preserveFocus: true, revealIfOpened: true, ignoreError: true }
588
607
  });
@@ -770,7 +789,8 @@ AnythingQuickAccessProvider = AnythingQuickAccessProvider_1 = ( __decorate([
770
789
  ( __param(15, IUriIdentityService)),
771
790
  ( __param(16, IQuickInputService)),
772
791
  ( __param(17, IKeybindingService)),
773
- ( __param(18, IQuickChatService))
792
+ ( __param(18, IQuickChatService)),
793
+ ( __param(19, ILogService))
774
794
  ], AnythingQuickAccessProvider));
775
795
 
776
796
  export { AnythingQuickAccessProvider };
@@ -1,6 +1,6 @@
1
1
  import n from '../../../../../../../../external/rollup-plugin-styles/dist/runtime/inject-css.js';
2
2
 
3
- var css = ".quick-input-list .quick-input-list-entry.has-actions:hover .quick-input-list-entry-action-bar .action-label.dirty-anything:before{content:\"\\ea76\"}";
3
+ var css = ".quick-input-list .quick-input-list-entry.has-actions:hover .quick-input-list-entry-action-bar .action-label.dirty-anything:before{content:\"\\ea76\";font-family:codicon}";
4
4
  n(css,{});
5
5
 
6
6
  export { css, css as default };
@@ -11,6 +11,7 @@ import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/c
11
11
  import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
12
12
  import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding';
13
13
  import { defaultToggleStyles } from 'vscode/vscode/vs/platform/theme/browser/defaultStyles';
14
+ import { getDefaultHoverDelegate } from 'vscode/vscode/vs/base/browser/ui/hover/hoverDelegateFactory';
14
15
 
15
16
  let PatternInputWidget = class PatternInputWidget extends Widget {
16
17
  static { this.OPTION_CHANGE = 'optionChange'; }
@@ -163,6 +164,7 @@ let IncludePatternInputWidget = class IncludePatternInputWidget extends PatternI
163
164
  "Search only in Open Editors"
164
165
  )),
165
166
  isChecked: false,
167
+ hoverDelegate: getDefaultHoverDelegate('element'),
166
168
  ...defaultToggleStyles
167
169
  })));
168
170
  this._register(this.useSearchInEditorsBox.onChange(viaKeyboard => {
@@ -210,6 +212,7 @@ let ExcludePatternInputWidget = class ExcludePatternInputWidget extends PatternI
210
212
  "Use Exclude Settings and Ignore Files"
211
213
  )),
212
214
  isChecked: true,
215
+ hoverDelegate: getDefaultHoverDelegate('element'),
213
216
  ...defaultToggleStyles
214
217
  })));
215
218
  this._register(this.useExcludesAndIgnoreFilesBox.onChange(viaKeyboard => {
@@ -21,9 +21,8 @@ import { SIDE_GROUP, ACTIVE_GROUP, IEditorService } from 'vscode/vscode/vs/workb
21
21
  import { QueryBuilder } from 'vscode/vscode/vs/workbench/services/search/common/queryBuilder';
22
22
  import { VIEW_ID } from 'vscode/vscode/vs/workbench/services/search/common/search';
23
23
  import { Event } from 'vscode/vscode/vs/base/common/event';
24
- import { EditorViewState } from 'vscode/vscode/vs/workbench/browser/quickaccess';
24
+ import { PickerEditorState } from 'vscode/vscode/vs/workbench/browser/quickaccess';
25
25
  import { IViewsService } from 'vscode/vscode/vs/workbench/services/views/common/viewsService';
26
- import { IHistoryService } from 'vscode/vscode/vs/workbench/services/history/common/history';
27
26
  import { Sequencer } from 'vscode/vscode/vs/base/common/async';
28
27
 
29
28
  const TEXT_SEARCH_QUICK_ACCESS_PREFIX = '%';
@@ -36,6 +35,7 @@ const DEFAULT_TEXT_QUERY_BUILDER_OPTIONS = {
36
35
  };
37
36
  const MAX_FILES_SHOWN = 30;
38
37
  const MAX_RESULTS_PER_FILE = 10;
38
+ const DEBOUNCE_DELAY = 75;
39
39
  let TextSearchQuickAccess = class TextSearchQuickAccess extends PickerQuickAccessProvider {
40
40
  _getTextQueryBuilderOptions(charsPerLine) {
41
41
  return {
@@ -51,7 +51,7 @@ let TextSearchQuickAccess = class TextSearchQuickAccess extends PickerQuickAcces
51
51
  }
52
52
  };
53
53
  }
54
- constructor(_instantiationService, _contextService, _editorService, _labelService, _viewsService, _configurationService, _historyService) {
54
+ constructor(_instantiationService, _contextService, _editorService, _labelService, _viewsService, _configurationService) {
55
55
  super(TEXT_SEARCH_QUICK_ACCESS_PREFIX, { canAcceptInBackground: true, shouldSkipTrimPickFilter: true });
56
56
  this._instantiationService = _instantiationService;
57
57
  this._contextService = _contextService;
@@ -59,14 +59,13 @@ let TextSearchQuickAccess = class TextSearchQuickAccess extends PickerQuickAcces
59
59
  this._labelService = _labelService;
60
60
  this._viewsService = _viewsService;
61
61
  this._configurationService = _configurationService;
62
- this._historyService = _historyService;
63
62
  this.currentAsyncSearch = Promise.resolve({
64
63
  results: [],
65
64
  messages: []
66
65
  });
67
- this.editorViewState = ( new EditorViewState(this._editorService));
68
66
  this.queryBuilder = this._instantiationService.createInstance(QueryBuilder);
69
- this.searchModel = this._instantiationService.createInstance(SearchModel);
67
+ this.searchModel = this._register(this._instantiationService.createInstance(SearchModel));
68
+ this.editorViewState = this._register(this._instantiationService.createInstance(PickerEditorState));
70
69
  this.searchModel.location = SearchModelLocation.QUICK_ACCESS;
71
70
  this.editorSequencer = ( new Sequencer());
72
71
  }
@@ -91,29 +90,26 @@ let TextSearchQuickAccess = class TextSearchQuickAccess extends PickerQuickAcces
91
90
  }
92
91
  picker.hide();
93
92
  }));
94
- disposables.add(picker.onDidChangeActive(() => {
93
+ const onDidChangeActive = () => {
95
94
  const [item] = picker.activeItems;
96
95
  if (item?.match) {
97
96
  this.editorViewState.set();
98
97
  const itemMatch = item.match;
99
98
  this.editorSequencer.queue(async () => {
100
- const disposable = this._historyService.suspendTracking();
101
- try {
102
- await this._editorService.openEditor({
103
- resource: itemMatch.parent().resource,
104
- options: { preserveFocus: true, revealIfOpened: true, ignoreError: true, selection: itemMatch.range() }
105
- });
106
- }
107
- finally {
108
- disposable.dispose();
109
- }
99
+ await this.editorViewState.openTransientEditor({
100
+ resource: itemMatch.parent().resource,
101
+ options: { preserveFocus: true, revealIfOpened: true, ignoreError: true, selection: itemMatch.range() }
102
+ });
110
103
  });
111
104
  }
112
- }));
113
- disposables.add(Event.once(picker.onDidHide)(({ reason }) => {
105
+ };
106
+ disposables.add(Event.debounce(picker.onDidChangeActive, (last, event) => event, DEBOUNCE_DELAY, true)(onDidChangeActive));
107
+ disposables.add(Event.once(picker.onWillHide)(({ reason }) => {
114
108
  if (reason === QuickInputHideReason.Gesture) {
115
- this.editorViewState.restore(true);
109
+ this.editorViewState.restore();
116
110
  }
111
+ }));
112
+ disposables.add(Event.once(picker.onDidHide)(({ reason }) => {
117
113
  this.searchModel.searchResult.toggleHighlights(false);
118
114
  }));
119
115
  disposables.add(super.provide(picker, token, runOptions));
@@ -203,7 +199,7 @@ let TextSearchQuickAccess = class TextSearchQuickAccess extends PickerQuickAcces
203
199
  picks.push({
204
200
  label,
205
201
  type: 'separator',
206
- tooltip: description,
202
+ description,
207
203
  buttons: [{
208
204
  iconClass: ThemeIcon.asClassName(searchOpenInFileIcon),
209
205
  tooltip: ( localizeWithPath(
@@ -212,6 +208,10 @@ let TextSearchQuickAccess = class TextSearchQuickAccess extends PickerQuickAcces
212
208
  "Open File"
213
209
  ))
214
210
  }],
211
+ trigger: async () => {
212
+ await this.handleAccept(fileMatch, {});
213
+ return TriggerAction.CLOSE_PICKER;
214
+ },
215
215
  });
216
216
  const results = fileMatch.matches() ?? [];
217
217
  for (let matchIndex = 0; matchIndex < results.length; matchIndex++) {
@@ -335,8 +335,7 @@ TextSearchQuickAccess = ( __decorate([
335
335
  ( __param(2, IEditorService)),
336
336
  ( __param(3, ILabelService)),
337
337
  ( __param(4, IViewsService)),
338
- ( __param(5, IConfigurationService)),
339
- ( __param(6, IHistoryService))
338
+ ( __param(5, IConfigurationService))
340
339
  ], TextSearchQuickAccess));
341
340
 
342
341
  export { TEXT_SEARCH_QUICK_ACCESS_PREFIX, TextSearchQuickAccess };
@@ -1,3 +1,4 @@
1
+ import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
1
2
  import { ReplacePreviewContentProvider } from './replaceService.js';
2
3
  import { registerWorkbenchContribution2 } from 'vscode/vscode/vs/workbench/common/contributions';
3
4
 
@@ -12,10 +12,14 @@ import { Extensions } from 'vscode/vscode/vs/workbench/common/views';
12
12
  import { GotoSymbolQuickAccessProvider } from 'vscode/vscode/vs/workbench/contrib/codeEditor/browser/quickaccess/gotoSymbolQuickAccess';
13
13
  import { AnythingQuickAccessProvider } from './anythingQuickAccess.js';
14
14
  import { registerContributions } from './replaceContributions.js';
15
+ import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
16
+ import 'vscode/vscode/vs/workbench/contrib/search/browser/notebookSearch/notebookSearchService';
15
17
  import { searchViewIcon } from './searchIcons.js';
16
18
  import { SearchView } from './searchView.js';
17
19
  import { registerContributions as registerContributions$1 } from './searchWidget.js';
18
20
  import { SymbolsQuickAccessProvider } from './symbolsQuickAccess.js';
21
+ import 'vscode/vscode/vs/workbench/contrib/search/common/searchHistoryService';
22
+ import 'vscode/vscode/vs/workbench/contrib/search/browser/searchModel';
19
23
  import { VIEWLET_ID, VIEW_ID, SEARCH_EXCLUDE_CONFIG } from 'vscode/vscode/vs/workbench/services/search/common/search';
20
24
  import { CommandsRegistry } from 'vscode/vscode/vs/platform/commands/common/commands';
21
25
  import { assertType } from 'vscode/vscode/vs/base/common/types';
@@ -147,7 +151,7 @@ configurationRegistry.registerConfiguration({
147
151
  markdownDescription: ( localizeWithPath(
148
152
  'vs/workbench/contrib/search/browser/search.contribution',
149
153
  'exclude',
150
- "Configure [glob patterns](https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options) for excluding files and folders in fulltext searches and quick open. Inherits all glob patterns from the `#files.exclude#` setting."
154
+ "Configure [glob patterns](https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options) for excluding files and folders in fulltext searches and file search in quick open. To exclude files from the recently opened list in quick open, patterns must be absolute (for example `**/node_modules/**`). Inherits all glob patterns from the `#files.exclude#` setting."
151
155
  )),
152
156
  default: { '**/node_modules': true, '**/bower_components': true, '**/*.code-search': true },
153
157
  additionalProperties: {
@@ -493,6 +497,28 @@ configurationRegistry.registerConfiguration({
493
497
  "Configure effect of double-clicking a result in a search editor."
494
498
  ))
495
499
  },
500
+ 'search.searchEditor.singleClickBehaviour': {
501
+ type: 'string',
502
+ enum: ['default', 'peekDefinition',],
503
+ default: 'default',
504
+ enumDescriptions: [
505
+ ( localizeWithPath(
506
+ 'vs/workbench/contrib/search/browser/search.contribution',
507
+ 'search.searchEditor.singleClickBehaviour.default',
508
+ "Single-clicking does nothing."
509
+ )),
510
+ ( localizeWithPath(
511
+ 'vs/workbench/contrib/search/browser/search.contribution',
512
+ 'search.searchEditor.singleClickBehaviour.peekDefinition',
513
+ "Single-clicking opens a Peek Definition window."
514
+ )),
515
+ ],
516
+ markdownDescription: ( localizeWithPath(
517
+ 'vs/workbench/contrib/search/browser/search.contribution',
518
+ 'search.searchEditor.singleClickBehaviour',
519
+ "Configure effect of single-clicking a result in a search editor."
520
+ ))
521
+ },
496
522
  'search.searchEditor.reusePriorSearchConfiguration': {
497
523
  type: 'boolean',
498
524
  default: false,
@@ -102,7 +102,7 @@ registerAction2(class CollapseDeepestExpandedLevelAction extends Action2 {
102
102
  menu: [{
103
103
  id: MenuId.ViewTitle,
104
104
  group: 'navigation',
105
- order: 3,
105
+ order: 4,
106
106
  when: ( ContextKeyExpr.and(( ContextKeyExpr.equals('view', VIEW_ID)), ( ContextKeyExpr.or(( SearchContext.HasSearchResults.negate()), SearchContext.ViewHasSomeCollapsibleKey)))),
107
107
  }]
108
108
  });
@@ -127,7 +127,7 @@ registerAction2(class ExpandAllAction extends Action2 {
127
127
  menu: [{
128
128
  id: MenuId.ViewTitle,
129
129
  group: 'navigation',
130
- order: 3,
130
+ order: 4,
131
131
  when: ( ContextKeyExpr.and(( ContextKeyExpr.equals('view', VIEW_ID)), SearchContext.HasSearchResults, ( SearchContext.ViewHasSomeCollapsibleKey.toNegated()))),
132
132
  }]
133
133
  });
@@ -1,28 +1,68 @@
1
1
  import { ContextScopedFindInput } from 'vscode/vscode/vs/platform/history/browser/contextScopedHistoryWidget';
2
2
  import { NotebookFindInputFilterButton } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindReplaceWidget';
3
3
  import { localizeWithPath } from 'vscode/vscode/vs/nls';
4
+ import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
5
+ import { getDefaultHoverDelegate } from 'vscode/vscode/vs/base/browser/ui/hover/hoverDelegateFactory';
6
+ import { Toggle } from 'vscode/vscode/vs/base/browser/ui/toggle/toggle';
7
+ import { Emitter } from 'vscode/vscode/vs/base/common/event';
4
8
 
9
+ const NLS_AI_TOGGLE_LABEL = ( localizeWithPath(
10
+ 'vs/workbench/contrib/search/browser/searchFindInput',
11
+ 'aiDescription',
12
+ "Use AI"
13
+ ));
5
14
  class SearchFindInput extends ContextScopedFindInput {
6
- constructor(container, contextViewProvider, options, contextKeyService, contextMenuService, instantiationService, filters, filterStartVisiblitity) {
15
+ constructor(container, contextViewProvider, options, contextKeyService, contextMenuService, instantiationService, filters, _shouldShowAIButton,
16
+ filterStartVisiblitity) {
7
17
  super(container, contextViewProvider, options, contextKeyService);
8
18
  this.contextMenuService = contextMenuService;
9
19
  this.instantiationService = instantiationService;
10
20
  this.filters = filters;
21
+ this._shouldShowAIButton = _shouldShowAIButton;
11
22
  this._filterChecked = false;
12
23
  this._visible = false;
24
+ this._onDidChangeAIToggle = this._register(( new Emitter()));
25
+ this.onDidChangeAIToggle = this._onDidChangeAIToggle.event;
13
26
  this._findFilter = this._register(( new NotebookFindInputFilterButton(filters, contextMenuService, instantiationService, options, ( localizeWithPath(
14
27
  'vs/workbench/contrib/search/browser/searchFindInput',
15
28
  'searchFindInputNotebookFilter.label',
16
29
  "Notebook Find Filters"
17
30
  )))));
31
+ this._aiButton = this._register(( new AIToggle({
32
+ appendTitle: '',
33
+ isChecked: false,
34
+ ...options.toggleStyles
35
+ })));
36
+ this.setAdditionalToggles([this._aiButton]);
18
37
  this.inputBox.paddingRight = (this.caseSensitive?.width() ?? 0) + (this.wholeWords?.width() ?? 0) + (this.regex?.width() ?? 0) + this._findFilter.width;
19
38
  this.controls.appendChild(this._findFilter.container);
20
39
  this._findFilter.container.classList.add('monaco-custom-toggle');
21
40
  this.filterVisible = filterStartVisiblitity;
41
+ this._register(this._aiButton.onChange(() => {
42
+ if (this._aiButton.checked) {
43
+ this.regex?.disable();
44
+ this.wholeWords?.disable();
45
+ this.caseSensitive?.disable();
46
+ this._findFilter.disable();
47
+ }
48
+ else {
49
+ this.regex?.enable();
50
+ this.wholeWords?.enable();
51
+ this.caseSensitive?.enable();
52
+ this._findFilter.enable();
53
+ }
54
+ }));
55
+ this._aiButton.domNode.style.display = _shouldShowAIButton ? '' : 'none';
22
56
  }
23
- set filterVisible(show) {
24
- this._findFilter.container.style.display = show ? '' : 'none';
25
- this._visible = show;
57
+ set shouldShowAIButton(visible) {
58
+ if (this._shouldShowAIButton !== visible) {
59
+ this._shouldShowAIButton = visible;
60
+ this._aiButton.domNode.style.display = visible ? '' : 'none';
61
+ }
62
+ }
63
+ set filterVisible(visible) {
64
+ this._findFilter.container.style.display = visible ? '' : 'none';
65
+ this._visible = visible;
26
66
  this.updateStyles();
27
67
  }
28
68
  setEnabled(enabled) {
@@ -42,6 +82,22 @@ class SearchFindInput extends ContextScopedFindInput {
42
82
  !this.filters.codeOutput;
43
83
  this._findFilter.applyStyles(this._filterChecked);
44
84
  }
85
+ get isAIEnabled() {
86
+ return this._aiButton.checked;
87
+ }
88
+ }
89
+ class AIToggle extends Toggle {
90
+ constructor(opts) {
91
+ super({
92
+ icon: Codicon.sparkle,
93
+ title: NLS_AI_TOGGLE_LABEL + opts.appendTitle,
94
+ isChecked: opts.isChecked,
95
+ hoverDelegate: opts.hoverDelegate ?? getDefaultHoverDelegate('element'),
96
+ inputActiveOptionBorder: opts.inputActiveOptionBorder,
97
+ inputActiveOptionForeground: opts.inputActiveOptionForeground,
98
+ inputActiveOptionBackground: opts.inputActiveOptionBackground
99
+ });
100
+ }
45
101
  }
46
102
 
47
103
  export { SearchFindInput };
@@ -92,5 +92,15 @@ const searchOpenInFileIcon = registerIcon('search-open-in-file', Codicon.goToFil
92
92
  'searchOpenInFile',
93
93
  'Icon for the action to go to the file of the current search result.'
94
94
  )));
95
+ registerIcon('search-sparkle-filled', Codicon.sparkleFilled, ( localizeWithPath(
96
+ 'vs/workbench/contrib/search/browser/searchIcons',
97
+ 'searchSparkleFilled',
98
+ 'Icon to show AI results in search.'
99
+ )));
100
+ registerIcon('search-sparkle-empty', Codicon.sparkle, ( localizeWithPath(
101
+ 'vs/workbench/contrib/search/browser/searchIcons',
102
+ 'searchSparkleEmpty',
103
+ 'Icon to hide AI results in search.'
104
+ )));
95
105
 
96
106
  export { searchActivityBarIcon, searchClearIcon, searchCollapseAllIcon, searchDetailsIcon, searchExpandAllIcon, searchHideReplaceIcon, searchNewEditorIcon, searchOpenInFileIcon, searchRefreshIcon, searchRemoveIcon, searchReplaceAllIcon, searchReplaceIcon, searchShowAsList, searchShowAsTree, searchShowContextIcon, searchShowReplaceIcon, searchStopIcon, searchViewIcon };
@@ -1,7 +1,7 @@
1
1
  import { localizeWithPath } from 'vscode/vscode/vs/nls';
2
2
  import { $, append } from 'vscode/vscode/vs/base/browser/dom';
3
3
  import { parseLinkedText } from 'vscode/vscode/vs/base/common/linkedText';
4
- import Severity from 'vscode/vscode/vs/base/common/severity';
4
+ import Severity$1 from 'vscode/vscode/vs/base/common/severity';
5
5
  import { SeverityIcon } from 'vscode/vscode/vs/platform/severityIcon/browser/severityIcon';
6
6
  import { TextSearchCompleteMessageType } from 'vscode/vscode/vs/workbench/services/search/common/searchExtTypes';
7
7
  import { Schemas } from 'vscode/vscode/vs/base/common/network';
@@ -13,8 +13,8 @@ const renderSearchMessage = (message, instantiationService, notificationService,
13
13
  const linkedText = parseLinkedText(message.text);
14
14
  append(div, $('.' +
15
15
  SeverityIcon.className(message.type === TextSearchCompleteMessageType.Information
16
- ? Severity.Info
17
- : Severity.Warning)
16
+ ? Severity$1.Info
17
+ : Severity$1.Warning)
18
18
  .split(' ')
19
19
  .join('.')));
20
20
  for (const node of linkedText.nodes) {
@@ -17,6 +17,8 @@ import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/
17
17
  import { ServiceCollection } from 'vscode/vscode/vs/platform/instantiation/common/serviceCollection';
18
18
  import { defaultCountBadgeStyles } from 'vscode/vscode/vs/platform/theme/browser/defaultStyles';
19
19
  import { SearchContext } from 'vscode/vscode/vs/workbench/contrib/search/common/constants';
20
+ import { setupCustomHover } from 'vscode/vscode/vs/base/browser/ui/hover/updatableHoverWidget';
21
+ import { getDefaultHoverDelegate } from 'vscode/vscode/vs/base/browser/ui/hover/hoverDelegateFactory';
20
22
 
21
23
  var FolderMatchRenderer_1, FileMatchRenderer_1, MatchRenderer_1;
22
24
  class SearchDelegate {
@@ -313,7 +315,8 @@ let MatchRenderer = class MatchRenderer extends Disposable {
313
315
  templateData.match.classList.toggle('replace', replace);
314
316
  templateData.replace.textContent = replace ? match.replaceString : '';
315
317
  templateData.after.textContent = preview.after;
316
- templateData.parent.title = (preview.fullBefore + (replace ? match.replaceString : preview.inside) + preview.after).trim().substr(0, 999);
318
+ const title = (preview.fullBefore + (replace ? match.replaceString : preview.inside) + preview.after).trim().substr(0, 999);
319
+ templateData.disposables.add(setupCustomHover(getDefaultHoverDelegate('mouse'), templateData.parent, title));
317
320
  SearchContext.IsEditableItemKey.bindTo(templateData.contextKeyService).set(!(match instanceof MatchInNotebook && match.isReadonly()));
318
321
  const numLines = match.range().endLineNumber - match.range().startLineNumber;
319
322
  const extraLinesStr = numLines > 0 ? `+${numLines}` : '';
@@ -321,7 +324,7 @@ let MatchRenderer = class MatchRenderer extends Disposable {
321
324
  const lineNumberStr = showLineNumbers ? `${match.range().startLineNumber}:` : '';
322
325
  templateData.lineNumber.classList.toggle('show', (numLines > 0) || showLineNumbers);
323
326
  templateData.lineNumber.textContent = lineNumberStr + extraLinesStr;
324
- templateData.lineNumber.setAttribute('title', this.getMatchTitle(match, showLineNumbers));
327
+ templateData.disposables.add(setupCustomHover(getDefaultHoverDelegate('mouse'), templateData.lineNumber, this.getMatchTitle(match, showLineNumbers)));
325
328
  templateData.actions.context = { viewer: this.searchView.getControl(), element: match };
326
329
  }
327
330
  disposeTemplate(templateData) {
@@ -15,7 +15,7 @@ import { Schemas } from 'vscode/vscode/vs/base/common/network';
15
15
  import './media/searchview.css.js';
16
16
  import { isCodeEditor, getCodeEditor, isDiffEditor } from 'vscode/vscode/vs/editor/browser/editorBrowser';
17
17
  import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
18
- import { EmbeddedCodeEditorWidget } from 'vscode/vscode/vs/editor/browser/widget/embeddedCodeEditorWidget';
18
+ import { EmbeddedCodeEditorWidget } from 'vscode/vscode/vs/editor/browser/widget/codeEditor/embeddedCodeEditorWidget';
19
19
  import { Selection } from 'vscode/vscode/vs/editor/common/core/selection';
20
20
  import { CommonFindController } from 'vscode/vscode/vs/editor/contrib/find/browser/findController';
21
21
  import { MultiCursorSelectionController } from 'vscode/vscode/vs/editor/contrib/multicursor/browser/multicursor';
@@ -68,6 +68,8 @@ import { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/c
68
68
  import { INotebookService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookService';
69
69
  import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
70
70
  import { AccessibilitySignal, IAccessibilitySignalService } from 'vscode/vscode/vs/platform/accessibilitySignal/browser/accessibilitySignalService';
71
+ import { setupCustomHover } from 'vscode/vscode/vs/base/browser/ui/hover/updatableHoverWidget';
72
+ import { getDefaultHoverDelegate } from 'vscode/vscode/vs/base/browser/ui/hover/hoverDelegateFactory';
71
73
  import { TextSearchCompleteMessageType } from 'vscode/vscode/vs/workbench/services/search/common/searchExtTypes';
72
74
  import { IDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
73
75
 
@@ -127,6 +129,13 @@ let SearchView = class SearchView extends ViewPane {
127
129
  this.hasFilePatternKey = SearchContext.ViewHasFilePatternKey.bindTo(this.contextKeyService);
128
130
  this.hasSomeCollapsibleResultKey = SearchContext.ViewHasSomeCollapsibleKey.bindTo(this.contextKeyService);
129
131
  this.treeViewKey = SearchContext.InTreeViewKey.bindTo(this.contextKeyService);
132
+ this.aiResultsVisibleKey = SearchContext.AIResultsVisibleKey.bindTo(this.contextKeyService);
133
+ this._register(this.contextKeyService.onDidChangeContext(e => {
134
+ const keys = ( SearchContext.hasAIResultProvider.keys());
135
+ if (e.affectsSome(( new Set(keys)))) {
136
+ this.refreshHasAISetting();
137
+ }
138
+ }));
130
139
  this.contextKeyService = this._register(this.contextKeyService.createScoped(this.container));
131
140
  SearchContext.SearchViewFocusedKey.bindTo(this.contextKeyService).set(true);
132
141
  this.inputBoxFocused = SearchContext.InputBoxFocusedKey.bindTo(this.contextKeyService);
@@ -134,14 +143,17 @@ let SearchView = class SearchView extends ViewPane {
134
143
  this.inputPatternExclusionsFocused = SearchContext.PatternExcludesFocusedKey.bindTo(this.contextKeyService);
135
144
  this.isEditableItem = SearchContext.IsEditableItemKey.bindTo(this.contextKeyService);
136
145
  this.instantiationService = this.instantiationService.createChild(( new ServiceCollection([IContextKeyService, this.contextKeyService])));
137
- this.configurationService.onDidChangeConfiguration(e => {
146
+ this._register(this.configurationService.onDidChangeConfiguration(e => {
138
147
  if (e.affectsConfiguration('search.sortOrder')) {
139
148
  if (this.searchConfig.sortOrder === "modified" ) {
140
149
  this.removeFileStats();
141
150
  }
142
151
  this.refreshTree();
143
152
  }
144
- });
153
+ else if (e.affectsConfiguration('search.aiResults')) {
154
+ this.refreshHasAISetting();
155
+ }
156
+ }));
145
157
  this.viewModel = this._register(this.searchViewModelWorkbenchService.searchModel);
146
158
  this.queryBuilder = this.instantiationService.createInstance(QueryBuilder);
147
159
  this.memento = ( new Memento(this.id, storageService));
@@ -183,6 +195,12 @@ let SearchView = class SearchView extends ViewPane {
183
195
  set isTreeLayoutViewVisible(visible) {
184
196
  this.treeViewKey.set(visible);
185
197
  }
198
+ get aiResultsVisible() {
199
+ return this.aiResultsVisibleKey.get() ?? false;
200
+ }
201
+ set aiResultsVisible(visible) {
202
+ this.aiResultsVisibleKey.set(visible);
203
+ }
186
204
  setTreeView(visible) {
187
205
  if (visible === this.isTreeLayoutViewVisible) {
188
206
  return;
@@ -191,6 +209,24 @@ let SearchView = class SearchView extends ViewPane {
191
209
  this.updateIndentStyles(this.themeService.getFileIconTheme());
192
210
  this.refreshTree();
193
211
  }
212
+ async setAIResultsVisible(visible) {
213
+ if (visible === this.aiResultsVisible) {
214
+ return;
215
+ }
216
+ this.aiResultsVisible = visible;
217
+ if (this.viewModel.searchResult.isEmpty()) {
218
+ return;
219
+ }
220
+ this.model.cancelAISearch();
221
+ if (visible) {
222
+ await this.model.addAIResults();
223
+ }
224
+ else {
225
+ this.searchWidget.toggleReplace(false);
226
+ }
227
+ this.onSearchResultsChanged();
228
+ this.onSearchComplete(() => { }, undefined, undefined, this.viewModel.searchResult.getCachedSearchComplete(visible));
229
+ }
194
230
  get state() {
195
231
  return this.searchStateKey.get() ?? SearchUIState.Idle;
196
232
  }
@@ -206,6 +242,12 @@ let SearchView = class SearchView extends ViewPane {
206
242
  get model() {
207
243
  return this.viewModel;
208
244
  }
245
+ refreshHasAISetting() {
246
+ const val = this.shouldShowAIButton();
247
+ if (val && this.searchWidget.searchInput) {
248
+ this.searchWidget.searchInput.shouldShowAIButton = val;
249
+ }
250
+ }
209
251
  onDidChangeWorkbenchState() {
210
252
  if (this.contextService.getWorkbenchState() !== 1 && this.searchWithoutFolderMessageElement) {
211
253
  hide(this.searchWithoutFolderMessageElement);
@@ -248,8 +290,8 @@ let SearchView = class SearchView extends ViewPane {
248
290
  this.onSearchError(e, progressComplete, undefined, undefined);
249
291
  });
250
292
  const collapseResults = this.searchConfig.collapseResults;
251
- if (collapseResults !== 'alwaysCollapse' && this.viewModel.searchResult.matches().length === 1) {
252
- const onlyMatch = this.viewModel.searchResult.matches()[0];
293
+ if (collapseResults !== 'alwaysCollapse' && this.viewModel.searchResult.matches(this.aiResultsVisible).length === 1) {
294
+ const onlyMatch = this.viewModel.searchResult.matches(this.aiResultsVisible)[0];
253
295
  if (onlyMatch.count() < 50) {
254
296
  this.tree.expand(onlyMatch);
255
297
  }
@@ -260,6 +302,7 @@ let SearchView = class SearchView extends ViewPane {
260
302
  this.container = append(parent, $$1('.search-view'));
261
303
  this.searchWidgetsContainerElement = append(this.container, $('.search-widgets-container'));
262
304
  this.createSearchWidget(this.searchWidgetsContainerElement);
305
+ this.refreshHasAISetting();
263
306
  const history = this.searchHistoryService.load();
264
307
  const filePatterns = this.viewletState['query.filePatterns'] || '';
265
308
  const patternExclusions = this.viewletState['query.folderExclusions'] || '';
@@ -271,11 +314,12 @@ let SearchView = class SearchView extends ViewPane {
271
314
  const useExcludesAndIgnoreFiles = typeof this.viewletState['query.useExcludesAndIgnoreFiles'] === 'boolean' ?
272
315
  this.viewletState['query.useExcludesAndIgnoreFiles'] : true;
273
316
  this.queryDetails = append(this.searchWidgetsContainerElement, $('.query-details'));
274
- this.toggleQueryDetailsButton = append(this.queryDetails, $('.more' + ThemeIcon.asCSSSelector(searchDetailsIcon), { tabindex: 0, role: 'button', title: ( localizeWithPath(
317
+ this.toggleQueryDetailsButton = append(this.queryDetails, $('.more' + ThemeIcon.asCSSSelector(searchDetailsIcon), { tabindex: 0, role: 'button' }));
318
+ this._register(setupCustomHover(getDefaultHoverDelegate('element'), this.toggleQueryDetailsButton, ( localizeWithPath(
275
319
  'vs/workbench/contrib/search/browser/searchView',
276
320
  'moreSearch',
277
321
  "Toggle Search Details"
278
- )) }));
322
+ ))));
279
323
  this._register(addDisposableListener(this.toggleQueryDetailsButton, EventType.CLICK, e => {
280
324
  EventHelper.stop(e);
281
325
  this.toggleQueryDetails(!this.accessibilityService.isScreenReaderOptimized());
@@ -424,7 +468,8 @@ let SearchView = class SearchView extends ViewPane {
424
468
  isInNotebookMarkdownPreview,
425
469
  isInNotebookCellInput,
426
470
  isInNotebookCellOutput,
427
- }
471
+ },
472
+ initialAIButtonVisibility: this.shouldShowAIButton()
428
473
  }));
429
474
  if (!this.searchWidget.searchInput || !this.searchWidget.replaceInput) {
430
475
  this.logService.warn(`Cannot fully create search widget. Search or replace input undefined. SearchInput: ${this.searchWidget.searchInput}, ReplaceInput: ${this.searchWidget.replaceInput}`);
@@ -435,7 +480,14 @@ let SearchView = class SearchView extends ViewPane {
435
480
  }
436
481
  this._register(this.searchWidget.onSearchSubmit(options => this.triggerQueryChange(options)));
437
482
  this._register(this.searchWidget.onSearchCancel(({ focus }) => this.cancelSearch(focus)));
438
- this._register(this.searchWidget.searchInput.onDidOptionChange(() => this.triggerQueryChange()));
483
+ this._register(this.searchWidget.searchInput.onDidOptionChange(() => {
484
+ if (this.searchWidget.searchInput && this.searchWidget.searchInput.isAIEnabled !== this.aiResultsVisible) {
485
+ this.setAIResultsVisible(this.searchWidget.searchInput.isAIEnabled);
486
+ }
487
+ else {
488
+ this.triggerQueryChange();
489
+ }
490
+ }));
439
491
  this._register(this.searchWidget.getNotebookFilters().onDidChange(() => this.triggerQueryChange()));
440
492
  const updateHasPatternKey = () => this.hasSearchPatternKey.set(this.searchWidget.searchInput ? (this.searchWidget.searchInput.getValue().length > 0) : false);
441
493
  updateHasPatternKey();
@@ -464,6 +516,10 @@ let SearchView = class SearchView extends ViewPane {
464
516
  this.trackInputBox(this.searchWidget.searchInputFocusTracker);
465
517
  this.trackInputBox(this.searchWidget.replaceInputFocusTracker);
466
518
  }
519
+ shouldShowAIButton() {
520
+ const hasProvider = SearchContext.hasAIResultProvider.getValue(this.contextKeyService);
521
+ return !!(this.configurationService.getValue('search.aiResults') && hasProvider);
522
+ }
467
523
  onConfigurationUpdated(event) {
468
524
  if (event && (event.affectsConfiguration('search.decorations.colors') || event.affectsConfiguration('search.decorations.badges'))) {
469
525
  this.refreshTree();
@@ -495,7 +551,7 @@ let SearchView = class SearchView extends ViewPane {
495
551
  }
496
552
  }
497
553
  refreshAndUpdateCount(event) {
498
- this.searchWidget.setReplaceAllActionState(!this.viewModel.searchResult.isEmpty());
554
+ this.searchWidget.setReplaceAllActionState(!this.viewModel.searchResult.isEmpty(this.aiResultsVisible));
499
555
  this.updateSearchResultCount(this.viewModel.searchResult.query.userDisabledExcludesAndIgnoreFiles, this.viewModel.searchResult.query?.onlyOpenEditors, event?.clearingAll);
500
556
  return this.refreshTree(event);
501
557
  }
@@ -524,7 +580,7 @@ let SearchView = class SearchView extends ViewPane {
524
580
  }
525
581
  }
526
582
  createResultIterator(collapseResults) {
527
- const folderMatches = this.searchResult.folderMatches()
583
+ const folderMatches = this.searchResult.folderMatches(this.aiResultsVisible)
528
584
  .filter(fm => !fm.isEmpty())
529
585
  .sort(searchMatchComparer);
530
586
  if (folderMatches.length === 1) {
@@ -552,7 +608,10 @@ let SearchView = class SearchView extends ViewPane {
552
608
  }));
553
609
  }
554
610
  createFileIterator(fileMatch) {
555
- const matches = fileMatch.matches().sort(searchMatchComparer);
611
+ let matches = fileMatch.matches().sort(searchMatchComparer);
612
+ if (!this.aiResultsVisible) {
613
+ matches = matches.filter(e => !e.aiContributed);
614
+ }
556
615
  return ( Iterable.map(matches, r => ({ element: r, incompressible: true })));
557
616
  }
558
617
  createIterator(match, collapseResults) {
@@ -1107,7 +1166,7 @@ let SearchView = class SearchView extends ViewPane {
1107
1166
  this.searchIncludePattern.getValue() === '';
1108
1167
  }
1109
1168
  hasSearchResults() {
1110
- return !this.viewModel.searchResult.isEmpty();
1169
+ return !this.viewModel.searchResult.isEmpty(this.aiResultsVisible);
1111
1170
  }
1112
1171
  clearSearchResults(clearInput = true) {
1113
1172
  this.viewModel.searchResult.clear();
@@ -1385,6 +1444,7 @@ let SearchView = class SearchView extends ViewPane {
1385
1444
  this.inputPatternIncludes.onSearchSubmit();
1386
1445
  });
1387
1446
  this.viewModel.cancelSearch(true);
1447
+ this.viewModel.cancelAISearch(true);
1388
1448
  this.currentSearchQ = this.currentSearchQ
1389
1449
  .then(() => this.doSearch(query, excludePatternText, includePatternText, triggeredOnType))
1390
1450
  .then(() => undefined, () => undefined);
@@ -1394,7 +1454,7 @@ let SearchView = class SearchView extends ViewPane {
1394
1454
  return;
1395
1455
  }
1396
1456
  try {
1397
- const fileCount = this.viewModel.searchResult.fileCount();
1457
+ const fileCount = this.viewModel.searchResult.fileCount(this.aiResultsVisible);
1398
1458
  if (this._visibleMatches !== fileCount) {
1399
1459
  this._visibleMatches = fileCount;
1400
1460
  this.refreshAndUpdateCount();
@@ -1409,13 +1469,13 @@ let SearchView = class SearchView extends ViewPane {
1409
1469
  progressComplete();
1410
1470
  this.onSearchResultsChanged();
1411
1471
  const collapseResults = this.searchConfig.collapseResults;
1412
- if (collapseResults !== 'alwaysCollapse' && this.viewModel.searchResult.matches().length === 1) {
1413
- const onlyMatch = this.viewModel.searchResult.matches()[0];
1472
+ if (collapseResults !== 'alwaysCollapse' && this.viewModel.searchResult.matches(this.aiResultsVisible).length === 1) {
1473
+ const onlyMatch = this.viewModel.searchResult.matches(this.aiResultsVisible)[0];
1414
1474
  if (onlyMatch.count() < 50) {
1415
1475
  this.tree.expand(onlyMatch);
1416
1476
  }
1417
1477
  }
1418
- const hasResults = !this.viewModel.searchResult.isEmpty();
1478
+ const hasResults = !this.viewModel.searchResult.isEmpty(this.aiResultsVisible);
1419
1479
  if (completed?.exit === 1 ) {
1420
1480
  return;
1421
1481
  }
@@ -1541,7 +1601,7 @@ let SearchView = class SearchView extends ViewPane {
1541
1601
  'vs/workbench/contrib/search/browser/searchView',
1542
1602
  'ariaSearchResultsStatus',
1543
1603
  "Search returned {0} results in {1} files",
1544
- this.viewModel.searchResult.count(),
1604
+ this.viewModel.searchResult.count(this.aiResultsVisible),
1545
1605
  this.viewModel.searchResult.fileCount()
1546
1606
  )));
1547
1607
  }
@@ -1589,6 +1649,16 @@ let SearchView = class SearchView extends ViewPane {
1589
1649
  this.tree.setFocus([]);
1590
1650
  this.viewModel.replaceString = this.searchWidget.getReplaceValue();
1591
1651
  const result = this.viewModel.search(query);
1652
+ if (this.aiResultsVisible) {
1653
+ const aiResult = this.viewModel.aiSearch({ ...query, contentPattern: query.contentPattern.pattern, type: 3 });
1654
+ return result.asyncResults.then(() => aiResult.then((complete) => {
1655
+ clearTimeout(slowTimer);
1656
+ this.onSearchComplete(progressComplete, excludePatternText, includePatternText, complete);
1657
+ }, (e) => {
1658
+ clearTimeout(slowTimer);
1659
+ this.onSearchError(e, progressComplete, excludePatternText, includePatternText);
1660
+ }));
1661
+ }
1592
1662
  return result.asyncResults.then((complete) => {
1593
1663
  clearTimeout(slowTimer);
1594
1664
  this.onSearchComplete(progressComplete, excludePatternText, includePatternText, complete);
@@ -1625,11 +1695,12 @@ let SearchView = class SearchView extends ViewPane {
1625
1695
  this.inputPatternIncludes.setOnlySearchInOpenEditors(false);
1626
1696
  }
1627
1697
  updateSearchResultCount(disregardExcludesAndIgnores, onlyOpenEditors, clear = false) {
1628
- const fileCount = this.viewModel.searchResult.fileCount();
1698
+ const fileCount = this.viewModel.searchResult.fileCount(this.aiResultsVisible);
1699
+ const resultCount = this.viewModel.searchResult.count(this.aiResultsVisible);
1629
1700
  this.hasSearchResultsKey.set(fileCount > 0);
1630
1701
  const msgWasHidden = this.messagesElement.style.display === 'none';
1631
1702
  const messageEl = this.clearMessage();
1632
- const resultMsg = clear ? '' : this.buildResultCountMessage(this.viewModel.searchResult.count(), fileCount);
1703
+ const resultMsg = clear ? '' : this.buildResultCountMessage(resultCount, fileCount);
1633
1704
  this.tree.ariaLabel = resultMsg + ( localizeWithPath(
1634
1705
  'vs/workbench/contrib/search/browser/searchView',
1635
1706
  'forTerm',
@@ -1862,7 +1933,13 @@ let SearchView = class SearchView extends ViewPane {
1862
1933
  if (!this.viewModel) {
1863
1934
  return;
1864
1935
  }
1865
- const matches = this.viewModel.searchResult.matches();
1936
+ let matches = this.viewModel.searchResult.matches();
1937
+ for (let i = 0, len = matches.length; i < len; i++) {
1938
+ if (( resource.toString()) === ( matches[i].resource.toString())) {
1939
+ this.viewModel.searchResult.remove(matches[i]);
1940
+ }
1941
+ }
1942
+ matches = this.viewModel.searchResult.matches(true);
1866
1943
  for (let i = 0, len = matches.length; i < len; i++) {
1867
1944
  if (( resource.toString()) === ( matches[i].resource.toString())) {
1868
1945
  this.viewModel.searchResult.remove(matches[i]);
@@ -1957,7 +2034,7 @@ let SearchView = class SearchView extends ViewPane {
1957
2034
  this.searchHistoryService.save(history);
1958
2035
  }
1959
2036
  async retrieveFileStats() {
1960
- const files = ( this.searchResult.matches().filter(f => !f.fileStat).map(f => f.resolveFileStat(this.fileService)));
2037
+ const files = ( this.searchResult.matches(this.aiResultsVisible).filter(f => !f.fileStat).map(f => f.resolveFileStat(this.fileService)));
1961
2038
  await Promise.all(files);
1962
2039
  }
1963
2040
  async updateFileStats(elements) {
@@ -1968,6 +2045,9 @@ let SearchView = class SearchView extends ViewPane {
1968
2045
  for (const fileMatch of this.searchResult.matches()) {
1969
2046
  fileMatch.fileStat = undefined;
1970
2047
  }
2048
+ for (const fileMatch of this.searchResult.matches(true)) {
2049
+ fileMatch.fileStat = undefined;
2050
+ }
1971
2051
  }
1972
2052
  dispose() {
1973
2053
  this.isDisposed = true;
@@ -2008,7 +2088,8 @@ SearchView = SearchView_1 = ( __decorate([
2008
2088
  class SearchLinkButton extends Disposable {
2009
2089
  constructor(label, handler, tooltip) {
2010
2090
  super();
2011
- this.element = $('a.pointer', { tabindex: 0, title: tooltip }, label);
2091
+ this.element = $('a.pointer', { tabindex: 0 }, label);
2092
+ this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), this.element, tooltip));
2012
2093
  this.addEventHandlers(handler);
2013
2094
  }
2014
2095
  addEventHandlers(handler) {
@@ -32,6 +32,8 @@ import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/c
32
32
  import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
33
33
  import { NotebookEditorInput } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookEditorInput';
34
34
  import { SearchFindInput } from './searchFindInput.js';
35
+ import { getDefaultHoverDelegate } from 'vscode/vscode/vs/base/browser/ui/hover/hoverDelegateFactory';
36
+ import { MutableDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
35
37
 
36
38
  var SearchWidget_1;
37
39
  const SingleLineInputHeight = 26;
@@ -132,18 +134,19 @@ let SearchWidget = class SearchWidget extends Widget {
132
134
  notebookOptions.isInNotebookCellOutput
133
135
  )));
134
136
  this._register(this._notebookFilters.onDidChange(() => {
135
- if (this.searchInput instanceof SearchFindInput) {
137
+ if (this.searchInput) {
136
138
  this.searchInput.updateStyles();
137
139
  }
138
140
  }));
139
141
  this._register(this.editorService.onDidEditorsChange((e) => {
140
- if (this.searchInput instanceof SearchFindInput &&
142
+ if (this.searchInput &&
141
143
  e.event.editor instanceof NotebookEditorInput &&
142
144
  ((e.event.kind === 4 || e.event.kind === 5) )) {
143
145
  this.searchInput.filterVisible = this._hasNotebookOpen();
144
146
  }
145
147
  }));
146
148
  this._replaceHistoryDelayer = ( new Delayer(500));
149
+ this._toggleReplaceButtonListener = this._register(( new MutableDisposable()));
147
150
  this.render(container, options);
148
151
  this.configurationService.onDidChangeConfiguration(e => {
149
152
  if (e.affectsConfiguration('editor.accessibilitySupport')) {
@@ -266,18 +269,19 @@ let SearchWidget = class SearchWidget extends Widget {
266
269
  buttonSecondaryBackground: undefined,
267
270
  buttonSecondaryForeground: undefined,
268
271
  buttonSecondaryHoverBackground: undefined,
269
- buttonSeparator: undefined
272
+ buttonSeparator: undefined,
273
+ title: ( localizeWithPath(
274
+ 'vs/workbench/contrib/search/browser/searchWidget',
275
+ 'search.replace.toggle.button.title',
276
+ "Toggle Replace"
277
+ )),
278
+ hoverDelegate: getDefaultHoverDelegate('element'),
270
279
  };
271
280
  this.toggleReplaceButton = this._register(( new Button(parent, opts)));
272
281
  this.toggleReplaceButton.element.setAttribute('aria-expanded', 'false');
273
282
  this.toggleReplaceButton.element.classList.add('toggle-replace-button');
274
283
  this.toggleReplaceButton.icon = searchHideReplaceIcon;
275
- this.toggleReplaceButton.onDidClick(() => this.onToggleReplaceButton());
276
- this.toggleReplaceButton.element.title = ( localizeWithPath(
277
- 'vs/workbench/contrib/search/browser/searchWidget',
278
- 'search.replace.toggle.button.title',
279
- "Toggle Replace"
280
- ));
284
+ this._toggleReplaceButtonListener.value = this.toggleReplaceButton.onDidClick(() => this.onToggleReplaceButton());
281
285
  }
282
286
  renderSearchInput(parent, options) {
283
287
  const inputOptions = {
@@ -312,6 +316,7 @@ let SearchWidget = class SearchWidget extends Widget {
312
316
  this.contextMenuService,
313
317
  this.instantiationService,
314
318
  this._notebookFilters,
319
+ options.initialAIButtonVisibility ?? false,
315
320
  this._hasNotebookOpen()
316
321
  )));
317
322
  this.searchInput.onKeyDown((keyboardEvent) => this.onSearchInputKeyDown(keyboardEvent));
@@ -350,6 +355,7 @@ let SearchWidget = class SearchWidget extends Widget {
350
355
  "Toggle Context Lines"
351
356
  )), this.keybindingService.lookupKeybinding(ToggleSearchEditorContextLinesCommandId)),
352
357
  icon: searchShowContextIcon,
358
+ hoverDelegate: getDefaultHoverDelegate('element'),
353
359
  ...defaultToggleStyles
354
360
  }));
355
361
  this._register(this.showContextToggle.onChange(() => this.onContextLinesChanged()));
@@ -482,6 +488,7 @@ let SearchWidget = class SearchWidget extends Widget {
482
488
  this.searchInput?.clearMessage();
483
489
  this.setReplaceAllActionState(false);
484
490
  if (this.searchConfiguration.searchOnType) {
491
+ const delayMultiplierFromAISearch = (this.searchInput && this.searchInput.isAIEnabled) ? 5 : 1;
485
492
  if (this.searchInput?.getRegex()) {
486
493
  try {
487
494
  const regex = ( new RegExp(this.searchInput.getValue(), 'ug'));
@@ -497,13 +504,13 @@ let SearchWidget = class SearchWidget extends Widget {
497
504
  const delayMultiplier = matchienessHeuristic < 50 ? 1 :
498
505
  matchienessHeuristic < 100 ? 5 :
499
506
  10;
500
- this.submitSearch(true, this.searchConfiguration.searchOnTypeDebouncePeriod * delayMultiplier);
507
+ this.submitSearch(true, this.searchConfiguration.searchOnTypeDebouncePeriod * delayMultiplier * delayMultiplierFromAISearch);
501
508
  }
502
509
  catch {
503
510
  }
504
511
  }
505
512
  else {
506
- this.submitSearch(true, this.searchConfiguration.searchOnTypeDebouncePeriod);
513
+ this.submitSearch(true, this.searchConfiguration.searchOnTypeDebouncePeriod * delayMultiplierFromAISearch);
507
514
  }
508
515
  }
509
516
  }
@@ -1,5 +1,5 @@
1
1
  import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import { isEqual, extname } from 'vscode/vscode/vs/base/common/resources';
2
+ import { extname, isEqual } from 'vscode/vscode/vs/base/common/resources';
3
3
  import { URI } from 'vscode/vscode/vs/base/common/uri';
4
4
  import { ToggleCaseSensitiveKeybinding, ToggleWholeWordKeybinding, ToggleRegexKeybinding } from 'vscode/vscode/vs/editor/contrib/find/browser/findModel';
5
5
  import { localizeWithPath, localize2WithPath } from 'vscode/vscode/vs/nls';
@@ -20,7 +20,7 @@ import { SearchContext } from 'vscode/vscode/vs/workbench/contrib/search/common/
20
20
  import { InSearchEditor, OpenNewEditorCommandId, OpenEditorCommandId, SearchEditorID, ToggleSearchEditorContextLinesCommandId, SearchEditorScheme } from 'vscode/vscode/vs/workbench/contrib/searchEditor/browser/constants';
21
21
  import { SearchEditor } from './searchEditor.js';
22
22
  import { openNewSearchEditor, createEditorFromSearchResult, toggleSearchEditorCaseSensitiveCommand, toggleSearchEditorWholeWordCommand, toggleSearchEditorRegexCommand, toggleSearchEditorContextLinesCommand, modifySearchEditorContextLinesCommand, selectAllSearchEditorMatchesCommand, openSearchEditor } from './searchEditorActions.js';
23
- import { SearchEditorInput, getOrMakeSearchEditorInput, SEARCH_EDITOR_EXT } from './searchEditorInput.js';
23
+ import { SearchEditorInput, SEARCH_EDITOR_EXT, getOrMakeSearchEditorInput } from './searchEditorInput.js';
24
24
  import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
25
25
  import { VIEW_ID } from 'vscode/vscode/vs/workbench/services/search/common/search';
26
26
  import { RegisteredEditorPriority, IEditorResolverService } from 'vscode/vscode/vs/workbench/services/editor/common/editorResolverService';
@@ -23,7 +23,17 @@ import { ILabelService } from 'vscode/vscode/vs/platform/label/common/label';
23
23
  import { LongRunningOperation, IEditorProgressService } from 'vscode/vscode/vs/platform/progress/common/progress';
24
24
  import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
25
25
  import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry';
26
- import { registerColor, inputBorder } from 'vscode/vscode/vs/platform/theme/common/colorRegistry';
26
+ import { registerColor } from 'vscode/vscode/vs/platform/theme/common/colorUtils';
27
+ import 'vscode/vscode/vs/platform/theme/common/colors/baseColors';
28
+ import 'vscode/vscode/vs/platform/theme/common/colors/chartsColors';
29
+ import 'vscode/vscode/vs/platform/theme/common/colors/editorColors';
30
+ import { inputBorder } from 'vscode/vscode/vs/platform/theme/common/colors/inputColors';
31
+ import 'vscode/vscode/vs/platform/theme/common/colors/listColors';
32
+ import 'vscode/vscode/vs/platform/theme/common/colors/menuColors';
33
+ import 'vscode/vscode/vs/platform/theme/common/colors/minimapColors';
34
+ import 'vscode/vscode/vs/platform/theme/common/colors/miscColors';
35
+ import 'vscode/vscode/vs/platform/theme/common/colors/quickpickColors';
36
+ import 'vscode/vscode/vs/platform/theme/common/colors/searchColors';
27
37
  import { IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeService';
28
38
  import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
29
39
  import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace';
@@ -47,6 +57,8 @@ import { UnusualLineTerminatorsDetector } from 'vscode/vscode/vs/editor/contrib/
47
57
  import { getInputBoxStyle, defaultToggleStyles } from 'vscode/vscode/vs/platform/theme/browser/defaultStyles';
48
58
  import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
49
59
  import { SearchContext } from 'vscode/vscode/vs/workbench/contrib/search/common/constants';
60
+ import { setupCustomHover } from 'vscode/vscode/vs/base/browser/ui/hover/updatableHoverWidget';
61
+ import { getDefaultHoverDelegate } from 'vscode/vscode/vs/base/browser/ui/hover/hoverDelegateFactory';
50
62
 
51
63
  var SearchEditor_1;
52
64
  const RESULT_LINE_REGEX = /^(\s+)(\d+)(: | )(\s*)(.*)$/;
@@ -56,8 +68,8 @@ let SearchEditor = class SearchEditor extends AbstractTextCodeEditor {
56
68
  static { this.ID = SearchEditorID; }
57
69
  static { this.SEARCH_EDITOR_VIEW_STATE_PREFERENCE_KEY = 'searchEditorViewState'; }
58
70
  get searchResultEditor() { return this.editorControl; }
59
- constructor(telemetryService, themeService, storageService, modelService, contextService, labelService, instantiationService, contextViewService, commandService, openerService, notificationService, progressService, textResourceService, editorGroupService, editorService, configurationService, fileService, logService) {
60
- super(SearchEditor_1.ID, telemetryService, instantiationService, storageService, textResourceService, themeService, editorService, editorGroupService, fileService);
71
+ constructor(group, telemetryService, themeService, storageService, modelService, contextService, labelService, instantiationService, contextViewService, commandService, openerService, notificationService, progressService, textResourceService, editorGroupService, editorService, configurationService, fileService, logService) {
72
+ super(SearchEditor_1.ID, group, telemetryService, instantiationService, storageService, textResourceService, themeService, editorService, editorGroupService, fileService);
61
73
  this.modelService = modelService;
62
74
  this.contextService = contextService;
63
75
  this.labelService = labelService;
@@ -102,11 +114,12 @@ let SearchEditor = class SearchEditor extends AbstractTextCodeEditor {
102
114
  }
103
115
  this._register(this.queryEditorWidget.onDidToggleContext(() => this.triggerSearch({ resetCursor: false })));
104
116
  this.includesExcludesContainer = append(container, $('.includes-excludes'));
105
- this.toggleQueryDetailsButton = append(this.includesExcludesContainer, $('.expand' + ThemeIcon.asCSSSelector(searchDetailsIcon), { tabindex: 0, role: 'button', title: ( localizeWithPath(
117
+ this.toggleQueryDetailsButton = append(this.includesExcludesContainer, $('.expand' + ThemeIcon.asCSSSelector(searchDetailsIcon), { tabindex: 0, role: 'button' }));
118
+ this._register(setupCustomHover(getDefaultHoverDelegate('element'), this.toggleQueryDetailsButton, ( localizeWithPath(
106
119
  'vs/workbench/contrib/searchEditor/browser/searchEditor',
107
120
  'moreSearch',
108
121
  "Toggle Search Details"
109
- )) }));
122
+ ))));
110
123
  this._register(addDisposableListener(this.toggleQueryDetailsButton, EventType.CLICK, e => {
111
124
  EventHelper.stop(e);
112
125
  this.toggleIncludesExcludes();
@@ -198,7 +211,18 @@ let SearchEditor = class SearchEditor extends AbstractTextCodeEditor {
198
211
  }
199
212
  registerEditorListeners() {
200
213
  this.searchResultEditor.onMouseUp(e => {
201
- if (e.event.detail === 2) {
214
+ if (e.event.detail === 1) {
215
+ const behaviour = this.searchConfig.searchEditor.singleClickBehaviour;
216
+ const position = e.target.position;
217
+ if (position && behaviour === 'peekDefinition') {
218
+ const line = this.searchResultEditor.getModel()?.getLineContent(position.lineNumber) ?? '';
219
+ if (line.match(FILE_LINE_REGEX) || line.match(RESULT_LINE_REGEX)) {
220
+ this.searchResultEditor.setSelection(Range.fromPositions(position));
221
+ this.commandService.executeCommand('editor.action.peekDefinition');
222
+ }
223
+ }
224
+ }
225
+ else if (e.event.detail === 2) {
202
226
  const behaviour = this.searchConfig.searchEditor.doubleClickBehaviour;
203
227
  const position = e.target.position;
204
228
  if (position && behaviour !== 'selectWord') {
@@ -573,7 +597,7 @@ let SearchEditor = class SearchEditor extends AbstractTextCodeEditor {
573
597
  }
574
598
  }
575
599
  getInput() {
576
- return this._input;
600
+ return this.input;
577
601
  }
578
602
  setSearchConfig(config) {
579
603
  this.priorConfig = config;
@@ -689,24 +713,24 @@ let SearchEditor = class SearchEditor extends AbstractTextCodeEditor {
689
713
  }
690
714
  };
691
715
  SearchEditor = SearchEditor_1 = ( __decorate([
692
- ( __param(0, ITelemetryService)),
693
- ( __param(1, IThemeService)),
694
- ( __param(2, IStorageService)),
695
- ( __param(3, IModelService)),
696
- ( __param(4, IWorkspaceContextService)),
697
- ( __param(5, ILabelService)),
698
- ( __param(6, IInstantiationService)),
699
- ( __param(7, IContextViewService)),
700
- ( __param(8, ICommandService)),
701
- ( __param(9, IOpenerService)),
702
- ( __param(10, INotificationService)),
703
- ( __param(11, IEditorProgressService)),
704
- ( __param(12, ITextResourceConfigurationService)),
705
- ( __param(13, IEditorGroupsService)),
706
- ( __param(14, IEditorService)),
707
- ( __param(15, IConfigurationService)),
708
- ( __param(16, IFileService)),
709
- ( __param(17, ILogService))
716
+ ( __param(1, ITelemetryService)),
717
+ ( __param(2, IThemeService)),
718
+ ( __param(3, IStorageService)),
719
+ ( __param(4, IModelService)),
720
+ ( __param(5, IWorkspaceContextService)),
721
+ ( __param(6, ILabelService)),
722
+ ( __param(7, IInstantiationService)),
723
+ ( __param(8, IContextViewService)),
724
+ ( __param(9, ICommandService)),
725
+ ( __param(10, IOpenerService)),
726
+ ( __param(11, INotificationService)),
727
+ ( __param(12, IEditorProgressService)),
728
+ ( __param(13, ITextResourceConfigurationService)),
729
+ ( __param(14, IEditorGroupsService)),
730
+ ( __param(15, IEditorService)),
731
+ ( __param(16, IConfigurationService)),
732
+ ( __param(17, IFileService)),
733
+ ( __param(18, ILogService))
710
734
  ], SearchEditor));
711
735
  const searchEditorTextInputBorder = registerColor('searchEditor.textInputBorder', { dark: inputBorder, light: inputBorder, hcDark: inputBorder, hcLight: inputBorder }, ( localizeWithPath(
712
736
  'vs/workbench/contrib/searchEditor/browser/searchEditor',
@@ -1,6 +1,6 @@
1
1
  import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
2
  import { coalesce, flatten, uniqueFilter } from 'vscode/vscode/vs/base/common/arrays';
3
- import { DeferredPromise } from 'vscode/vscode/vs/base/common/async';
3
+ import { raceCancellationError, DeferredPromise } from 'vscode/vscode/vs/base/common/async';
4
4
  import { CancellationError } from 'vscode/vscode/vs/base/common/errors';
5
5
  import { Disposable, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
6
6
  import { ResourceMap, ResourceSet } from 'vscode/vscode/vs/base/common/map';
@@ -30,8 +30,10 @@ let SearchService = class SearchService extends Disposable {
30
30
  this.uriIdentityService = uriIdentityService;
31
31
  this.fileSearchProviders = ( new Map());
32
32
  this.textSearchProviders = ( new Map());
33
+ this.aiTextSearchProviders = ( new Map());
33
34
  this.deferredFileSearchesByScheme = ( new Map());
34
35
  this.deferredTextSearchesByScheme = ( new Map());
36
+ this.deferredAITextSearchesByScheme = ( new Map());
35
37
  this.loggedSchemesMissingProviders = ( new Set());
36
38
  }
37
39
  registerSearchResultProvider(scheme, type, provider) {
@@ -45,6 +47,10 @@ let SearchService = class SearchService extends Disposable {
45
47
  list = this.textSearchProviders;
46
48
  deferredMap = this.deferredTextSearchesByScheme;
47
49
  }
50
+ else if (type === 2 ) {
51
+ list = this.aiTextSearchProviders;
52
+ deferredMap = this.deferredAITextSearchesByScheme;
53
+ }
48
54
  else {
49
55
  throw new Error('Unknown SearchProviderType');
50
56
  }
@@ -67,6 +73,22 @@ let SearchService = class SearchService extends Disposable {
67
73
  messages: [...otherResults.messages, ...openEditorResults.messages]
68
74
  };
69
75
  }
76
+ async aiTextSearch(query, token, onProgress) {
77
+ const onProviderProgress = (progress) => {
78
+ if (onProgress) {
79
+ if (isFileMatch(progress)) {
80
+ onProgress(progress);
81
+ }
82
+ else {
83
+ onProgress(progress);
84
+ }
85
+ }
86
+ if (isProgressMessage(progress)) {
87
+ this.logService.debug('SearchService#search', progress.message);
88
+ }
89
+ };
90
+ return this.doSearch(query, token, onProviderProgress);
91
+ }
70
92
  textSearchSplitSyncAsync(query, token, onProgress, notebookFilesToIgnore, asyncNotebookFilesToIgnore) {
71
93
  const openEditorResults = this.getOpenEditorResults(query);
72
94
  if (onProgress) {
@@ -138,14 +160,7 @@ let SearchService = class SearchService extends Disposable {
138
160
  results: flatten(( completes.map((c) => c.results)))
139
161
  };
140
162
  })();
141
- return ( new Promise((resolve, reject) => {
142
- if (token) {
143
- token.onCancellationRequested(() => {
144
- reject(( new CancellationError()));
145
- });
146
- }
147
- providerPromise.then(resolve, reject);
148
- }));
163
+ return token ? raceCancellationError(providerPromise, token) : providerPromise;
149
164
  }
150
165
  getSchemesInQuery(query) {
151
166
  const schemes = ( new Set());
@@ -154,9 +169,7 @@ let SearchService = class SearchService extends Disposable {
154
169
  return schemes;
155
170
  }
156
171
  async waitForProvider(queryType, scheme) {
157
- const deferredMap = queryType === 1 ?
158
- this.deferredFileSearchesByScheme :
159
- this.deferredTextSearchesByScheme;
172
+ const deferredMap = this.getDeferredTextSearchesByScheme(queryType);
160
173
  if (( deferredMap.has(scheme))) {
161
174
  return deferredMap.get(scheme).p;
162
175
  }
@@ -166,20 +179,43 @@ let SearchService = class SearchService extends Disposable {
166
179
  return deferred.p;
167
180
  }
168
181
  }
182
+ getSearchProvider(type) {
183
+ switch (type) {
184
+ case 1 :
185
+ return this.fileSearchProviders;
186
+ case 2 :
187
+ return this.textSearchProviders;
188
+ case 3 :
189
+ return this.aiTextSearchProviders;
190
+ default:
191
+ throw new Error(`Unknown query type: ${type}`);
192
+ }
193
+ }
194
+ getDeferredTextSearchesByScheme(type) {
195
+ switch (type) {
196
+ case 1 :
197
+ return this.deferredFileSearchesByScheme;
198
+ case 2 :
199
+ return this.deferredTextSearchesByScheme;
200
+ case 3 :
201
+ return this.deferredAITextSearchesByScheme;
202
+ default:
203
+ throw new Error(`Unknown query type: ${type}`);
204
+ }
205
+ }
169
206
  async searchWithProviders(query, onProviderProgress, token) {
170
207
  const e2eSW = StopWatch.create(false);
171
208
  const searchPs = [];
172
209
  const fqs = this.groupFolderQueriesByScheme(query);
173
210
  const someSchemeHasProvider = ( [...( fqs.keys())].some(scheme => {
174
- return query.type === 1 ?
175
- ( this.fileSearchProviders.has(scheme)) :
176
- ( this.textSearchProviders.has(scheme));
211
+ return ( this.getSearchProvider(query.type).has(scheme));
177
212
  }));
213
+ if (query.type === 3 && !someSchemeHasProvider) {
214
+ return [];
215
+ }
178
216
  await Promise.all(( [...( fqs.keys())].map(async (scheme) => {
179
217
  const schemeFQs = fqs.get(scheme);
180
- let provider = query.type === 1 ?
181
- this.fileSearchProviders.get(scheme) :
182
- this.textSearchProviders.get(scheme);
218
+ let provider = this.getSearchProvider(query.type).get(scheme);
183
219
  if (!provider) {
184
220
  if (someSchemeHasProvider) {
185
221
  if (!( this.loggedSchemesMissingProviders.has(scheme))) {
@@ -202,9 +238,17 @@ let SearchService = class SearchService extends Disposable {
202
238
  folderQueries: schemeFQs
203
239
  }
204
240
  };
205
- searchPs.push(query.type === 1 ?
206
- provider.fileSearch(oneSchemeQuery, token) :
207
- provider.textSearch(oneSchemeQuery, onProviderProgress, token));
241
+ const doProviderSearch = () => {
242
+ switch (query.type) {
243
+ case 1 :
244
+ return provider.fileSearch(oneSchemeQuery, token);
245
+ case 2 :
246
+ return provider.textSearch(oneSchemeQuery, onProviderProgress, token);
247
+ default:
248
+ return provider.textSearch(oneSchemeQuery, onProviderProgress, token);
249
+ }
250
+ };
251
+ searchPs.push(doProviderSearch());
208
252
  })));
209
253
  return Promise.all(searchPs).then(completes => {
210
254
  const endToEndTime = e2eSW.elapsed();