@codingame/monaco-vscode-search-service-override 4.1.0 → 4.1.2

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.
Files changed (35) hide show
  1. package/external/rollup-plugin-styles/dist/runtime/inject-css.js +3 -0
  2. package/external/tslib/tslib.es6.js +11 -0
  3. package/override/vs/platform/dialogs/common/dialogs.js +10 -0
  4. package/package.json +2 -2
  5. package/search.js +4 -4
  6. package/vscode/src/vs/workbench/contrib/search/browser/anythingQuickAccess.js +796 -0
  7. package/vscode/src/vs/workbench/contrib/search/browser/media/anythingQuickAccess.css.js +6 -0
  8. package/vscode/src/vs/workbench/contrib/search/browser/media/searchview.css.js +6 -0
  9. package/vscode/src/vs/workbench/contrib/search/browser/patternInputWidget.js +234 -0
  10. package/vscode/src/vs/workbench/contrib/search/browser/quickTextSearch/textSearchQuickAccess.js +341 -0
  11. package/vscode/src/vs/workbench/contrib/search/browser/replaceContributions.js +9 -0
  12. package/vscode/src/vs/workbench/contrib/search/browser/replaceService.js +232 -0
  13. package/vscode/src/vs/workbench/contrib/search/browser/search.contribution.js +647 -0
  14. package/vscode/src/vs/workbench/contrib/search/browser/searchActionsCopy.js +209 -0
  15. package/vscode/src/vs/workbench/contrib/search/browser/searchActionsNav.js +511 -0
  16. package/vscode/src/vs/workbench/contrib/search/browser/searchActionsRemoveReplace.js +374 -0
  17. package/vscode/src/vs/workbench/contrib/search/browser/searchActionsSymbol.js +43 -0
  18. package/vscode/src/vs/workbench/contrib/search/browser/searchActionsTextQuickAccess.js +44 -0
  19. package/vscode/src/vs/workbench/contrib/search/browser/searchActionsTopBar.js +323 -0
  20. package/vscode/src/vs/workbench/contrib/search/browser/searchFindInput.js +103 -0
  21. package/vscode/src/vs/workbench/contrib/search/browser/searchIcons.js +106 -0
  22. package/vscode/src/vs/workbench/contrib/search/browser/searchMessage.js +66 -0
  23. package/vscode/src/vs/workbench/contrib/search/browser/searchResultsView.js +437 -0
  24. package/vscode/src/vs/workbench/contrib/search/browser/searchView.js +2177 -0
  25. package/vscode/src/vs/workbench/contrib/search/browser/searchWidget.js +674 -0
  26. package/vscode/src/vs/workbench/contrib/search/browser/symbolsQuickAccess.js +234 -0
  27. package/vscode/src/vs/workbench/contrib/search/common/cacheState.js +87 -0
  28. package/vscode/src/vs/workbench/contrib/searchEditor/browser/media/searchEditor.css.js +6 -0
  29. package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditor.contribution.js +586 -0
  30. package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditor.js +760 -0
  31. package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditorActions.js +189 -0
  32. package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditorInput.js +320 -0
  33. package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditorModel.js +138 -0
  34. package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditorSerialization.js +293 -0
  35. package/vscode/src/vs/workbench/services/search/common/searchService.js +416 -0
@@ -0,0 +1,796 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import './media/anythingQuickAccess.css.js';
3
+ import { QuickPickItemScorerAccessor, QuickInputHideReason, quickPickItemScorerAccessor, IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput';
4
+ import { PickerQuickAccessProvider, TriggerAction } from 'vscode/vscode/vs/platform/quickinput/browser/pickerQuickAccess';
5
+ import { prepareQuery, compareItemsByFuzzyScore, scoreItemFuzzy } from 'vscode/vscode/vs/base/common/fuzzyScorer';
6
+ import { QueryBuilder } from 'vscode/vscode/vs/workbench/services/search/common/queryBuilder';
7
+ import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
8
+ import { extractRangeFromFilter, getOutOfWorkspaceEditorResources } from 'vscode/vscode/vs/workbench/contrib/search/common/search';
9
+ import { ISearchService } from 'vscode/vscode/vs/workbench/services/search/common/search';
10
+ import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace';
11
+ import { untildify } from 'vscode/vscode/vs/base/common/labels';
12
+ import { IPathService } from 'vscode/vscode/vs/workbench/services/path/common/pathService';
13
+ import { URI } from 'vscode/vscode/vs/base/common/uri';
14
+ import { toLocalResource, basenameOrAuthority, dirname } from 'vscode/vscode/vs/base/common/resources';
15
+ import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService';
16
+ import { IFileService } from 'vscode/vscode/vs/platform/files/common/files';
17
+ import { Disposable, DisposableStore, MutableDisposable, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
18
+ import { ILabelService } from 'vscode/vscode/vs/platform/label/common/label';
19
+ import { getIconClasses } from 'vscode/vscode/vs/editor/common/services/getIconClasses';
20
+ import { IModelService } from 'vscode/vscode/vs/editor/common/services/model';
21
+ import { ILanguageService } from 'vscode/vscode/vs/editor/common/languages/language';
22
+ import { localizeWithPath } from 'vscode/vscode/vs/nls';
23
+ import { IWorkingCopyService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyService';
24
+ import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
25
+ import { isEditorInput, EditorResourceAccessor } from 'vscode/vscode/vs/workbench/common/editor';
26
+ import { SIDE_GROUP, ACTIVE_GROUP, IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
27
+ import { Range } from 'vscode/vscode/vs/editor/common/core/range';
28
+ import { ThrottledDelayer } from 'vscode/vscode/vs/base/common/async';
29
+ import { top } from 'vscode/vscode/vs/base/common/arrays';
30
+ import { FileQueryCacheState } from '../common/cacheState.js';
31
+ import { IHistoryService } from 'vscode/vscode/vs/workbench/services/history/common/history';
32
+ import { Schemas } from 'vscode/vscode/vs/base/common/network';
33
+ import { IFilesConfigurationService } from 'vscode/vscode/vs/workbench/services/filesConfiguration/common/filesConfigurationService';
34
+ import { ResourceMap } from 'vscode/vscode/vs/base/common/map';
35
+ import { SymbolsQuickAccessProvider } from './symbolsQuickAccess.js';
36
+ import { DefaultQuickAccessFilterValue, Extensions } from 'vscode/vscode/vs/platform/quickinput/common/quickAccess';
37
+ import { PickerEditorState } from 'vscode/vscode/vs/workbench/browser/quickaccess';
38
+ import { GotoSymbolQuickAccessProvider } from 'vscode/vscode/vs/workbench/contrib/codeEditor/browser/quickaccess/gotoSymbolQuickAccess';
39
+ import { ITextModelService } from 'vscode/vscode/vs/editor/common/services/resolverService';
40
+ import { Event } from 'vscode/vscode/vs/base/common/event';
41
+ import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
42
+ import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
43
+ import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity';
44
+ import { stripIcons } from 'vscode/vscode/vs/base/common/iconLabels';
45
+ import { Lazy } from 'vscode/vscode/vs/base/common/lazy';
46
+ import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding';
47
+ import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
48
+ import { ASK_QUICK_QUESTION_ACTION_ID } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions';
49
+ import { IQuickChatService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat';
50
+ import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
51
+
52
+ var AnythingQuickAccessProvider_1;
53
+ function isEditorSymbolQuickPickItem(pick) {
54
+ const candidate = pick;
55
+ return !!candidate?.range && !!candidate.resource;
56
+ }
57
+ let AnythingQuickAccessProvider = class AnythingQuickAccessProvider extends PickerQuickAccessProvider {
58
+ static { AnythingQuickAccessProvider_1 = this; }
59
+ static { this.PREFIX = ''; }
60
+ static { this.NO_RESULTS_PICK = {
61
+ label: ( localizeWithPath(
62
+ 'vs/workbench/contrib/search/browser/anythingQuickAccess',
63
+ 'noAnythingResults',
64
+ "No matching results"
65
+ ))
66
+ }; }
67
+ static { this.MAX_RESULTS = 512; }
68
+ static { this.TYPING_SEARCH_DELAY = 200; }
69
+ static { this.SYMBOL_PICKS_MERGE_DELAY = 200; }
70
+ get defaultFilterValue() {
71
+ if (this.configuration.preserveInput) {
72
+ return DefaultQuickAccessFilterValue.LAST;
73
+ }
74
+ return undefined;
75
+ }
76
+ constructor(instantiationService, searchService, contextService, pathService, environmentService, fileService, labelService, modelService, languageService, workingCopyService, configurationService, editorService, historyService, filesConfigurationService, textModelService, uriIdentityService, quickInputService, keybindingService, quickChatService, logService) {
77
+ super(AnythingQuickAccessProvider_1.PREFIX, {
78
+ canAcceptInBackground: true,
79
+ noResultsPick: AnythingQuickAccessProvider_1.NO_RESULTS_PICK
80
+ });
81
+ this.instantiationService = instantiationService;
82
+ this.searchService = searchService;
83
+ this.contextService = contextService;
84
+ this.pathService = pathService;
85
+ this.environmentService = environmentService;
86
+ this.fileService = fileService;
87
+ this.labelService = labelService;
88
+ this.modelService = modelService;
89
+ this.languageService = languageService;
90
+ this.workingCopyService = workingCopyService;
91
+ this.configurationService = configurationService;
92
+ this.editorService = editorService;
93
+ this.historyService = historyService;
94
+ this.filesConfigurationService = filesConfigurationService;
95
+ this.textModelService = textModelService;
96
+ this.uriIdentityService = uriIdentityService;
97
+ this.quickInputService = quickInputService;
98
+ this.keybindingService = keybindingService;
99
+ this.quickChatService = quickChatService;
100
+ this.logService = logService;
101
+ this.pickState = this._register(new (class extends Disposable {
102
+ constructor(provider, instantiationService) {
103
+ super();
104
+ this.provider = provider;
105
+ this.instantiationService = instantiationService;
106
+ this.picker = undefined;
107
+ this.editorViewState = this._register(this.instantiationService.createInstance(PickerEditorState));
108
+ this.scorerCache = Object.create(null);
109
+ this.fileQueryCache = undefined;
110
+ this.lastOriginalFilter = undefined;
111
+ this.lastFilter = undefined;
112
+ this.lastRange = undefined;
113
+ this.lastGlobalPicks = undefined;
114
+ this.isQuickNavigating = undefined;
115
+ }
116
+ set(picker) {
117
+ this.picker = picker;
118
+ Event.once(picker.onDispose)(() => {
119
+ if (picker === this.picker) {
120
+ this.picker = undefined;
121
+ }
122
+ });
123
+ const isQuickNavigating = !!picker.quickNavigate;
124
+ if (!isQuickNavigating) {
125
+ this.fileQueryCache = this.provider.createFileQueryCache();
126
+ this.scorerCache = Object.create(null);
127
+ }
128
+ this.isQuickNavigating = isQuickNavigating;
129
+ this.lastOriginalFilter = undefined;
130
+ this.lastFilter = undefined;
131
+ this.lastRange = undefined;
132
+ this.lastGlobalPicks = undefined;
133
+ this.editorViewState.reset();
134
+ }
135
+ })(this, this.instantiationService));
136
+ this.labelOnlyEditorHistoryPickAccessor = ( new QuickPickItemScorerAccessor({ skipDescription: true }));
137
+ this.fileQueryDelayer = this._register(( new ThrottledDelayer(AnythingQuickAccessProvider_1.TYPING_SEARCH_DELAY)));
138
+ this.fileQueryBuilder = this.instantiationService.createInstance(QueryBuilder);
139
+ this.lazyRegistry = ( new Lazy(() => ( Registry.as(Extensions.Quickaccess))));
140
+ this.workspaceSymbolsQuickAccess = this._register(this.instantiationService.createInstance(SymbolsQuickAccessProvider));
141
+ this.editorSymbolsQuickAccess = this.instantiationService.createInstance(GotoSymbolQuickAccessProvider);
142
+ }
143
+ get configuration() {
144
+ const editorConfig = this.configurationService.getValue().workbench?.editor;
145
+ const searchConfig = this.configurationService.getValue().search;
146
+ const quickAccessConfig = this.configurationService.getValue().workbench.quickOpen;
147
+ return {
148
+ openEditorPinned: !editorConfig?.enablePreviewFromQuickOpen || !editorConfig?.enablePreview,
149
+ openSideBySideDirection: editorConfig?.openSideBySideDirection,
150
+ includeSymbols: searchConfig?.quickOpen.includeSymbols,
151
+ includeHistory: searchConfig?.quickOpen.includeHistory,
152
+ historyFilterSortOrder: searchConfig?.quickOpen.history.filterSortOrder,
153
+ preserveInput: quickAccessConfig.preserveInput
154
+ };
155
+ }
156
+ provide(picker, token, runOptions) {
157
+ const disposables = ( new DisposableStore());
158
+ this.pickState.set(picker);
159
+ const editorDecorationsDisposable = disposables.add(( new MutableDisposable()));
160
+ disposables.add(picker.onDidChangeActive(() => {
161
+ editorDecorationsDisposable.value = undefined;
162
+ const [item] = picker.activeItems;
163
+ if (isEditorSymbolQuickPickItem(item)) {
164
+ editorDecorationsDisposable.value = this.decorateAndRevealSymbolRange(item);
165
+ }
166
+ }));
167
+ disposables.add(Event.once(picker.onDidHide)(({ reason }) => {
168
+ if (reason === QuickInputHideReason.Gesture) {
169
+ this.pickState.editorViewState.restore();
170
+ }
171
+ }));
172
+ disposables.add(super.provide(picker, token, runOptions));
173
+ return disposables;
174
+ }
175
+ decorateAndRevealSymbolRange(pick) {
176
+ const activeEditor = this.editorService.activeEditor;
177
+ if (!this.uriIdentityService.extUri.isEqual(pick.resource, activeEditor?.resource)) {
178
+ return Disposable.None;
179
+ }
180
+ const activeEditorControl = this.editorService.activeTextEditorControl;
181
+ if (!activeEditorControl) {
182
+ return Disposable.None;
183
+ }
184
+ this.pickState.editorViewState.set();
185
+ activeEditorControl.revealRangeInCenter(pick.range.selection, 0 );
186
+ this.addDecorations(activeEditorControl, pick.range.decoration);
187
+ return toDisposable(() => this.clearDecorations(activeEditorControl));
188
+ }
189
+ _getPicks(originalFilter, disposables, token, runOptions) {
190
+ const filterWithRange = extractRangeFromFilter(originalFilter, [GotoSymbolQuickAccessProvider.PREFIX]);
191
+ let filter;
192
+ if (filterWithRange) {
193
+ filter = filterWithRange.filter;
194
+ }
195
+ else {
196
+ filter = originalFilter;
197
+ }
198
+ this.pickState.lastRange = filterWithRange?.range;
199
+ if (originalFilter !== this.pickState.lastOriginalFilter && filter === this.pickState.lastFilter) {
200
+ return null;
201
+ }
202
+ const lastWasFiltering = !!this.pickState.lastOriginalFilter;
203
+ this.pickState.lastOriginalFilter = originalFilter;
204
+ this.pickState.lastFilter = filter;
205
+ const picks = this.pickState.picker?.items;
206
+ const activePick = this.pickState.picker?.activeItems[0];
207
+ if (picks && activePick) {
208
+ const activePickIsEditorSymbol = isEditorSymbolQuickPickItem(activePick);
209
+ const activePickIsNoResultsInEditorSymbols = activePick === AnythingQuickAccessProvider_1.NO_RESULTS_PICK && filter.indexOf(GotoSymbolQuickAccessProvider.PREFIX) >= 0;
210
+ if (!activePickIsEditorSymbol && !activePickIsNoResultsInEditorSymbols) {
211
+ this.pickState.lastGlobalPicks = {
212
+ items: picks,
213
+ active: activePick
214
+ };
215
+ }
216
+ }
217
+ return this.doGetPicks(filter, {
218
+ ...runOptions,
219
+ enableEditorSymbolSearch: lastWasFiltering
220
+ }, disposables, token);
221
+ }
222
+ doGetPicks(filter, options, disposables, token) {
223
+ const query = prepareQuery(filter);
224
+ if (options.enableEditorSymbolSearch) {
225
+ const editorSymbolPicks = this.getEditorSymbolPicks(query, disposables, token);
226
+ if (editorSymbolPicks) {
227
+ return editorSymbolPicks;
228
+ }
229
+ }
230
+ const activePick = this.pickState.picker?.activeItems[0];
231
+ if (isEditorSymbolQuickPickItem(activePick) && this.pickState.lastGlobalPicks) {
232
+ return this.pickState.lastGlobalPicks;
233
+ }
234
+ const historyEditorPicks = this.getEditorHistoryPicks(query);
235
+ let picks = ( new Array());
236
+ if (options.additionPicks) {
237
+ picks.push(...options.additionPicks);
238
+ }
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
+ }
247
+ picks = historyEditorPicks;
248
+ }
249
+ else {
250
+ if (options.includeHelp) {
251
+ picks.push(...this.getHelpPicks(query, token, options));
252
+ }
253
+ if (historyEditorPicks.length !== 0) {
254
+ picks.push({ type: 'separator', label: ( localizeWithPath(
255
+ 'vs/workbench/contrib/search/browser/anythingQuickAccess',
256
+ 'recentlyOpenedSeparator',
257
+ "recently opened"
258
+ )) });
259
+ picks.push(...historyEditorPicks);
260
+ }
261
+ }
262
+ return {
263
+ picks,
264
+ additionalPicks: (async () => {
265
+ const additionalPicksExcludes = ( new ResourceMap());
266
+ for (const historyEditorPick of historyEditorPicks) {
267
+ if (historyEditorPick.resource) {
268
+ additionalPicksExcludes.set(historyEditorPick.resource, true);
269
+ }
270
+ }
271
+ const additionalPicks = await this.getAdditionalPicks(query, additionalPicksExcludes, token);
272
+ if (token.isCancellationRequested) {
273
+ return [];
274
+ }
275
+ return additionalPicks.length > 0 ? [
276
+ { type: 'separator', label: this.configuration.includeSymbols ? ( localizeWithPath(
277
+ 'vs/workbench/contrib/search/browser/anythingQuickAccess',
278
+ 'fileAndSymbolResultsSeparator',
279
+ "file and symbol results"
280
+ )) : ( localizeWithPath(
281
+ 'vs/workbench/contrib/search/browser/anythingQuickAccess',
282
+ 'fileResultsSeparator',
283
+ "file results"
284
+ )) },
285
+ ...additionalPicks
286
+ ] : [];
287
+ })(),
288
+ mergeDelay: AnythingQuickAccessProvider_1.SYMBOL_PICKS_MERGE_DELAY
289
+ };
290
+ }
291
+ async getAdditionalPicks(query, excludes, token) {
292
+ const [filePicks, symbolPicks] = await Promise.all([
293
+ this.getFilePicks(query, excludes, token),
294
+ this.getWorkspaceSymbolPicks(query, token)
295
+ ]);
296
+ if (token.isCancellationRequested) {
297
+ return [];
298
+ }
299
+ const sortedAnythingPicks = top([...filePicks, ...symbolPicks], (anyPickA, anyPickB) => compareItemsByFuzzyScore(anyPickA, anyPickB, query, true, quickPickItemScorerAccessor, this.pickState.scorerCache), AnythingQuickAccessProvider_1.MAX_RESULTS);
300
+ const filteredAnythingPicks = [];
301
+ for (const anythingPick of sortedAnythingPicks) {
302
+ if (anythingPick.highlights) {
303
+ filteredAnythingPicks.push(anythingPick);
304
+ }
305
+ else {
306
+ const { score, labelMatch, descriptionMatch } = scoreItemFuzzy(anythingPick, query, true, quickPickItemScorerAccessor, this.pickState.scorerCache);
307
+ if (!score) {
308
+ continue;
309
+ }
310
+ anythingPick.highlights = {
311
+ label: labelMatch,
312
+ description: descriptionMatch
313
+ };
314
+ filteredAnythingPicks.push(anythingPick);
315
+ }
316
+ }
317
+ return filteredAnythingPicks;
318
+ }
319
+ getEditorHistoryPicks(query) {
320
+ const configuration = this.configuration;
321
+ if (!query.normalized) {
322
+ return ( this.historyService.getHistory().map(editor => this.createAnythingPick(editor, configuration)));
323
+ }
324
+ if (!this.configuration.includeHistory) {
325
+ return [];
326
+ }
327
+ const editorHistoryScorerAccessor = query.containsPathSeparator ? quickPickItemScorerAccessor : this.labelOnlyEditorHistoryPickAccessor;
328
+ const editorHistoryPicks = [];
329
+ for (const editor of this.historyService.getHistory()) {
330
+ const resource = editor.resource;
331
+ if (!resource || (!this.fileService.hasProvider(resource) && resource.scheme !== Schemas.untitled && resource.scheme !== Schemas.vscodeTerminal)) {
332
+ continue;
333
+ }
334
+ const editorHistoryPick = this.createAnythingPick(editor, configuration);
335
+ const { score, labelMatch, descriptionMatch } = scoreItemFuzzy(editorHistoryPick, query, false, editorHistoryScorerAccessor, this.pickState.scorerCache);
336
+ if (!score) {
337
+ continue;
338
+ }
339
+ editorHistoryPick.highlights = {
340
+ label: labelMatch,
341
+ description: descriptionMatch
342
+ };
343
+ editorHistoryPicks.push(editorHistoryPick);
344
+ }
345
+ if (this.configuration.historyFilterSortOrder === 'recency') {
346
+ return editorHistoryPicks;
347
+ }
348
+ return editorHistoryPicks.sort((editorA, editorB) => compareItemsByFuzzyScore(editorA, editorB, query, false, editorHistoryScorerAccessor, this.pickState.scorerCache));
349
+ }
350
+ createFileQueryCache() {
351
+ return ( new FileQueryCacheState(
352
+ cacheKey => this.fileQueryBuilder.file(this.contextService.getWorkspace().folders, this.getFileQueryOptions({ cacheKey })),
353
+ query => this.searchService.fileSearch(query),
354
+ cacheKey => this.searchService.clearCache(cacheKey),
355
+ this.pickState.fileQueryCache
356
+ )).load();
357
+ }
358
+ async getFilePicks(query, excludes, token) {
359
+ if (!query.normalized) {
360
+ return [];
361
+ }
362
+ const absolutePathResult = await this.getAbsolutePathFileResult(query, token);
363
+ if (token.isCancellationRequested) {
364
+ return [];
365
+ }
366
+ let fileMatches;
367
+ if (absolutePathResult) {
368
+ if (( excludes.has(absolutePathResult))) {
369
+ return [];
370
+ }
371
+ const absolutePathPick = this.createAnythingPick(absolutePathResult, this.configuration);
372
+ absolutePathPick.highlights = {
373
+ label: [{ start: 0, end: absolutePathPick.label.length }],
374
+ description: absolutePathPick.description ? [{ start: 0, end: absolutePathPick.description.length }] : undefined
375
+ };
376
+ return [absolutePathPick];
377
+ }
378
+ if (this.pickState.fileQueryCache?.isLoaded) {
379
+ fileMatches = await this.doFileSearch(query, token);
380
+ }
381
+ else {
382
+ fileMatches = await this.fileQueryDelayer.trigger(async () => {
383
+ if (token.isCancellationRequested) {
384
+ return [];
385
+ }
386
+ return this.doFileSearch(query, token);
387
+ });
388
+ }
389
+ if (token.isCancellationRequested) {
390
+ return [];
391
+ }
392
+ const configuration = this.configuration;
393
+ return ( fileMatches
394
+ .filter(resource => !( excludes.has(resource)))
395
+ .map(resource => this.createAnythingPick(resource, configuration)));
396
+ }
397
+ async doFileSearch(query, token) {
398
+ const [fileSearchResults, relativePathFileResults] = await Promise.all([
399
+ this.getFileSearchResults(query, token),
400
+ this.getRelativePathFileResults(query, token)
401
+ ]);
402
+ if (token.isCancellationRequested) {
403
+ return [];
404
+ }
405
+ if (!relativePathFileResults) {
406
+ return fileSearchResults;
407
+ }
408
+ const relativePathFileResultsMap = ( new ResourceMap());
409
+ for (const relativePathFileResult of relativePathFileResults) {
410
+ relativePathFileResultsMap.set(relativePathFileResult, true);
411
+ }
412
+ return [
413
+ ...fileSearchResults.filter(result => !( relativePathFileResultsMap.has(result))),
414
+ ...relativePathFileResults
415
+ ];
416
+ }
417
+ async getFileSearchResults(query, token) {
418
+ let filePattern = '';
419
+ if (query.values && query.values.length > 1) {
420
+ filePattern = query.values[0].original;
421
+ }
422
+ else {
423
+ filePattern = query.original;
424
+ }
425
+ const fileSearchResults = await this.doGetFileSearchResults(filePattern, token);
426
+ if (token.isCancellationRequested) {
427
+ return [];
428
+ }
429
+ if (fileSearchResults.limitHit && query.values && query.values.length > 1) {
430
+ const additionalFileSearchResults = await this.doGetFileSearchResults(query.original, token);
431
+ if (token.isCancellationRequested) {
432
+ return [];
433
+ }
434
+ const existingFileSearchResultsMap = ( new ResourceMap());
435
+ for (const fileSearchResult of fileSearchResults.results) {
436
+ existingFileSearchResultsMap.set(fileSearchResult.resource, true);
437
+ }
438
+ for (const additionalFileSearchResult of additionalFileSearchResults.results) {
439
+ if (!( existingFileSearchResultsMap.has(additionalFileSearchResult.resource))) {
440
+ fileSearchResults.results.push(additionalFileSearchResult);
441
+ }
442
+ }
443
+ }
444
+ return ( fileSearchResults.results.map(result => result.resource));
445
+ }
446
+ doGetFileSearchResults(filePattern, token) {
447
+ const start = Date.now();
448
+ return this.searchService.fileSearch(this.fileQueryBuilder.file(this.contextService.getWorkspace().folders, this.getFileQueryOptions({
449
+ filePattern,
450
+ cacheKey: this.pickState.fileQueryCache?.cacheKey,
451
+ maxResults: AnythingQuickAccessProvider_1.MAX_RESULTS
452
+ })), token).finally(() => {
453
+ this.logService.trace(`QuickAccess fileSearch ${Date.now() - start}ms`);
454
+ });
455
+ }
456
+ getFileQueryOptions(input) {
457
+ return {
458
+ _reason: 'openFileHandler',
459
+ extraFileResources: this.instantiationService.invokeFunction(getOutOfWorkspaceEditorResources),
460
+ filePattern: input.filePattern || '',
461
+ cacheKey: input.cacheKey,
462
+ maxResults: input.maxResults || 0,
463
+ sortByScore: true
464
+ };
465
+ }
466
+ async getAbsolutePathFileResult(query, token) {
467
+ if (!query.containsPathSeparator) {
468
+ return;
469
+ }
470
+ const userHome = await this.pathService.userHome();
471
+ const detildifiedQuery = untildify(query.original, userHome.scheme === Schemas.file ? userHome.fsPath : userHome.path);
472
+ if (token.isCancellationRequested) {
473
+ return;
474
+ }
475
+ const isAbsolutePathQuery = (await this.pathService.path).isAbsolute(detildifiedQuery);
476
+ if (token.isCancellationRequested) {
477
+ return;
478
+ }
479
+ if (isAbsolutePathQuery) {
480
+ const resource = toLocalResource(await this.pathService.fileURI(detildifiedQuery), this.environmentService.remoteAuthority, this.pathService.defaultUriScheme);
481
+ if (token.isCancellationRequested) {
482
+ return;
483
+ }
484
+ try {
485
+ if ((await this.fileService.stat(resource)).isFile) {
486
+ return resource;
487
+ }
488
+ }
489
+ catch (error) {
490
+ }
491
+ }
492
+ return;
493
+ }
494
+ async getRelativePathFileResults(query, token) {
495
+ if (!query.containsPathSeparator) {
496
+ return;
497
+ }
498
+ const isAbsolutePathQuery = (await this.pathService.path).isAbsolute(query.original);
499
+ if (!isAbsolutePathQuery) {
500
+ const resources = [];
501
+ for (const folder of this.contextService.getWorkspace().folders) {
502
+ if (token.isCancellationRequested) {
503
+ break;
504
+ }
505
+ const resource = toLocalResource(folder.toResource(query.original), this.environmentService.remoteAuthority, this.pathService.defaultUriScheme);
506
+ try {
507
+ if ((await this.fileService.stat(resource)).isFile) {
508
+ resources.push(resource);
509
+ }
510
+ }
511
+ catch (error) {
512
+ }
513
+ }
514
+ return resources;
515
+ }
516
+ return;
517
+ }
518
+ getHelpPicks(query, token, runOptions) {
519
+ if (query.normalized) {
520
+ return [];
521
+ }
522
+ const providers = this.lazyRegistry.value.getQuickAccessProviders()
523
+ .filter(p => ( p.helpEntries.some(h => h.commandCenterOrder !== undefined)))
524
+ .flatMap(provider => ( provider.helpEntries
525
+ .filter(h => h.commandCenterOrder !== undefined)
526
+ .map(helpEntry => {
527
+ const providerSpecificOptions = {
528
+ ...runOptions,
529
+ includeHelp: provider.prefix === AnythingQuickAccessProvider_1.PREFIX ? false : runOptions?.includeHelp
530
+ };
531
+ const label = helpEntry.commandCenterLabel ?? helpEntry.description;
532
+ return {
533
+ label,
534
+ description: helpEntry.prefix ?? provider.prefix,
535
+ commandCenterOrder: helpEntry.commandCenterOrder,
536
+ keybinding: helpEntry.commandId ? this.keybindingService.lookupKeybinding(helpEntry.commandId) : undefined,
537
+ ariaLabel: ( localizeWithPath(
538
+ 'vs/workbench/contrib/search/browser/anythingQuickAccess',
539
+ 'helpPickAriaLabel',
540
+ "{0}, {1}",
541
+ label,
542
+ helpEntry.description
543
+ )),
544
+ accept: () => {
545
+ this.quickInputService.quickAccess.show(provider.prefix, {
546
+ preserveValue: true,
547
+ providerOptions: providerSpecificOptions
548
+ });
549
+ }
550
+ };
551
+ })));
552
+ if (this.quickChatService.enabled) {
553
+ providers.push({
554
+ label: ( localizeWithPath(
555
+ 'vs/workbench/contrib/search/browser/anythingQuickAccess',
556
+ 'chat',
557
+ "Open Quick Chat"
558
+ )),
559
+ commandCenterOrder: 30,
560
+ keybinding: this.keybindingService.lookupKeybinding(ASK_QUICK_QUESTION_ACTION_ID),
561
+ accept: () => this.quickChatService.toggle()
562
+ });
563
+ }
564
+ return providers.sort((a, b) => a.commandCenterOrder - b.commandCenterOrder);
565
+ }
566
+ async getWorkspaceSymbolPicks(query, token) {
567
+ const configuration = this.configuration;
568
+ if (!query.normalized ||
569
+ !configuration.includeSymbols ||
570
+ this.pickState.lastRange
571
+ ) {
572
+ return [];
573
+ }
574
+ return this.workspaceSymbolsQuickAccess.getSymbolPicks(query.original, {
575
+ skipLocal: true,
576
+ skipSorting: true,
577
+ delay: AnythingQuickAccessProvider_1.TYPING_SEARCH_DELAY
578
+ }, token);
579
+ }
580
+ getEditorSymbolPicks(query, disposables, token) {
581
+ const filterSegments = query.original.split(GotoSymbolQuickAccessProvider.PREFIX);
582
+ const filter = filterSegments.length > 1 ? filterSegments[filterSegments.length - 1].trim() : undefined;
583
+ if (typeof filter !== 'string') {
584
+ return null;
585
+ }
586
+ const activeGlobalPick = this.pickState.lastGlobalPicks?.active;
587
+ if (!activeGlobalPick) {
588
+ return null;
589
+ }
590
+ const activeGlobalResource = activeGlobalPick.resource;
591
+ if (!activeGlobalResource || (!this.fileService.hasProvider(activeGlobalResource) && activeGlobalResource.scheme !== Schemas.untitled)) {
592
+ return null;
593
+ }
594
+ if (activeGlobalPick.label.includes(GotoSymbolQuickAccessProvider.PREFIX) || activeGlobalPick.description?.includes(GotoSymbolQuickAccessProvider.PREFIX)) {
595
+ if (filterSegments.length < 3) {
596
+ return null;
597
+ }
598
+ }
599
+ return this.doGetEditorSymbolPicks(activeGlobalPick, activeGlobalResource, filter, disposables, token);
600
+ }
601
+ async doGetEditorSymbolPicks(activeGlobalPick, activeGlobalResource, filter, disposables, token) {
602
+ try {
603
+ this.pickState.editorViewState.set();
604
+ await this.pickState.editorViewState.openTransientEditor({
605
+ resource: activeGlobalResource,
606
+ options: { preserveFocus: true, revealIfOpened: true, ignoreError: true }
607
+ });
608
+ }
609
+ catch (error) {
610
+ return [];
611
+ }
612
+ if (token.isCancellationRequested) {
613
+ return [];
614
+ }
615
+ let model = this.modelService.getModel(activeGlobalResource);
616
+ if (!model) {
617
+ try {
618
+ const modelReference = disposables.add(await this.textModelService.createModelReference(activeGlobalResource));
619
+ if (token.isCancellationRequested) {
620
+ return [];
621
+ }
622
+ model = modelReference.object.textEditorModel;
623
+ }
624
+ catch (error) {
625
+ return [];
626
+ }
627
+ }
628
+ const editorSymbolPicks = (await this.editorSymbolsQuickAccess.getSymbolPicks(model, filter, { extraContainerLabel: stripIcons(activeGlobalPick.label) }, disposables, token));
629
+ if (token.isCancellationRequested) {
630
+ return [];
631
+ }
632
+ return ( editorSymbolPicks.map(editorSymbolPick => {
633
+ if (editorSymbolPick.type === 'separator') {
634
+ return editorSymbolPick;
635
+ }
636
+ return {
637
+ ...editorSymbolPick,
638
+ resource: activeGlobalResource,
639
+ description: editorSymbolPick.description,
640
+ trigger: (buttonIndex, keyMods) => {
641
+ this.openAnything(activeGlobalResource, { keyMods, range: editorSymbolPick.range?.selection, forceOpenSideBySide: true });
642
+ return TriggerAction.CLOSE_PICKER;
643
+ },
644
+ accept: (keyMods, event) => this.openAnything(activeGlobalResource, { keyMods, range: editorSymbolPick.range?.selection, preserveFocus: event.inBackground, forcePinned: event.inBackground })
645
+ };
646
+ }));
647
+ }
648
+ addDecorations(editor, range) {
649
+ this.editorSymbolsQuickAccess.addDecorations(editor, range);
650
+ }
651
+ clearDecorations(editor) {
652
+ this.editorSymbolsQuickAccess.clearDecorations(editor);
653
+ }
654
+ createAnythingPick(resourceOrEditor, configuration) {
655
+ const isEditorHistoryEntry = !URI.isUri(resourceOrEditor);
656
+ let resource;
657
+ let label;
658
+ let description = undefined;
659
+ let isDirty = undefined;
660
+ let extraClasses;
661
+ let icon = undefined;
662
+ if (isEditorInput(resourceOrEditor)) {
663
+ resource = EditorResourceAccessor.getOriginalUri(resourceOrEditor);
664
+ label = resourceOrEditor.getName();
665
+ description = resourceOrEditor.getDescription();
666
+ isDirty = resourceOrEditor.isDirty() && !resourceOrEditor.isSaving();
667
+ extraClasses = resourceOrEditor.getLabelExtraClasses();
668
+ icon = resourceOrEditor.getIcon();
669
+ }
670
+ else {
671
+ resource = URI.isUri(resourceOrEditor) ? resourceOrEditor : resourceOrEditor.resource;
672
+ label = basenameOrAuthority(resource);
673
+ description = this.labelService.getUriLabel(dirname(resource), { relative: true });
674
+ isDirty = this.workingCopyService.isDirty(resource) && !this.filesConfigurationService.hasShortAutoSaveDelay(resource);
675
+ extraClasses = [];
676
+ }
677
+ const labelAndDescription = description ? `${label} ${description}` : label;
678
+ const iconClassesValue = ( new Lazy(
679
+ () => getIconClasses(this.modelService, this.languageService, resource, undefined, icon).concat(extraClasses)
680
+ ));
681
+ const buttonsValue = ( new Lazy(() => {
682
+ const openSideBySideDirection = configuration.openSideBySideDirection;
683
+ const buttons = [];
684
+ buttons.push({
685
+ iconClass: openSideBySideDirection === 'right' ? ThemeIcon.asClassName(Codicon.splitHorizontal) : ThemeIcon.asClassName(Codicon.splitVertical),
686
+ tooltip: openSideBySideDirection === 'right' ?
687
+ ( localizeWithPath(
688
+ 'vs/workbench/contrib/search/browser/anythingQuickAccess',
689
+ { key: 'openToSide', comment: ['Open this file in a split editor on the left/right side'] },
690
+ "Open to the Side"
691
+ )) :
692
+ ( localizeWithPath(
693
+ 'vs/workbench/contrib/search/browser/anythingQuickAccess',
694
+ { key: 'openToBottom', comment: ['Open this file in a split editor on the bottom'] },
695
+ "Open to the Bottom"
696
+ ))
697
+ });
698
+ if (isEditorHistoryEntry) {
699
+ buttons.push({
700
+ iconClass: isDirty ? ('dirty-anything ' + ThemeIcon.asClassName(Codicon.circleFilled)) : ThemeIcon.asClassName(Codicon.close),
701
+ tooltip: ( localizeWithPath(
702
+ 'vs/workbench/contrib/search/browser/anythingQuickAccess',
703
+ 'closeEditor',
704
+ "Remove from Recently Opened"
705
+ )),
706
+ alwaysVisible: isDirty
707
+ });
708
+ }
709
+ return buttons;
710
+ }));
711
+ return {
712
+ resource,
713
+ label,
714
+ ariaLabel: isDirty ? ( localizeWithPath(
715
+ 'vs/workbench/contrib/search/browser/anythingQuickAccess',
716
+ 'filePickAriaLabelDirty',
717
+ "{0} unsaved changes",
718
+ labelAndDescription
719
+ )) : labelAndDescription,
720
+ description,
721
+ get iconClasses() { return iconClassesValue.value; },
722
+ get buttons() { return buttonsValue.value; },
723
+ trigger: (buttonIndex, keyMods) => {
724
+ switch (buttonIndex) {
725
+ case 0:
726
+ this.openAnything(resourceOrEditor, { keyMods, range: this.pickState.lastRange, forceOpenSideBySide: true });
727
+ return TriggerAction.CLOSE_PICKER;
728
+ case 1:
729
+ if (!URI.isUri(resourceOrEditor)) {
730
+ this.historyService.removeFromHistory(resourceOrEditor);
731
+ return TriggerAction.REMOVE_ITEM;
732
+ }
733
+ }
734
+ return TriggerAction.NO_ACTION;
735
+ },
736
+ accept: (keyMods, event) => this.openAnything(resourceOrEditor, { keyMods, range: this.pickState.lastRange, preserveFocus: event.inBackground, forcePinned: event.inBackground })
737
+ };
738
+ }
739
+ async openAnything(resourceOrEditor, options) {
740
+ const editorOptions = {
741
+ preserveFocus: options.preserveFocus,
742
+ pinned: options.keyMods?.ctrlCmd || options.forcePinned || this.configuration.openEditorPinned,
743
+ selection: options.range ? Range.collapseToStart(options.range) : undefined
744
+ };
745
+ const targetGroup = options.keyMods?.alt || (this.configuration.openEditorPinned && options.keyMods?.ctrlCmd) || options.forceOpenSideBySide ? SIDE_GROUP : ACTIVE_GROUP;
746
+ if (targetGroup === SIDE_GROUP) {
747
+ await this.pickState.editorViewState.restore();
748
+ }
749
+ if (isEditorInput(resourceOrEditor)) {
750
+ await this.editorService.openEditor(resourceOrEditor, editorOptions, targetGroup);
751
+ }
752
+ else {
753
+ let resourceEditorInput;
754
+ if (URI.isUri(resourceOrEditor)) {
755
+ resourceEditorInput = {
756
+ resource: resourceOrEditor,
757
+ options: editorOptions
758
+ };
759
+ }
760
+ else {
761
+ resourceEditorInput = {
762
+ ...resourceOrEditor,
763
+ options: {
764
+ ...resourceOrEditor.options,
765
+ ...editorOptions
766
+ }
767
+ };
768
+ }
769
+ await this.editorService.openEditor(resourceEditorInput, targetGroup);
770
+ }
771
+ }
772
+ };
773
+ AnythingQuickAccessProvider = AnythingQuickAccessProvider_1 = ( __decorate([
774
+ ( __param(0, IInstantiationService)),
775
+ ( __param(1, ISearchService)),
776
+ ( __param(2, IWorkspaceContextService)),
777
+ ( __param(3, IPathService)),
778
+ ( __param(4, IWorkbenchEnvironmentService)),
779
+ ( __param(5, IFileService)),
780
+ ( __param(6, ILabelService)),
781
+ ( __param(7, IModelService)),
782
+ ( __param(8, ILanguageService)),
783
+ ( __param(9, IWorkingCopyService)),
784
+ ( __param(10, IConfigurationService)),
785
+ ( __param(11, IEditorService)),
786
+ ( __param(12, IHistoryService)),
787
+ ( __param(13, IFilesConfigurationService)),
788
+ ( __param(14, ITextModelService)),
789
+ ( __param(15, IUriIdentityService)),
790
+ ( __param(16, IQuickInputService)),
791
+ ( __param(17, IKeybindingService)),
792
+ ( __param(18, IQuickChatService)),
793
+ ( __param(19, ILogService))
794
+ ], AnythingQuickAccessProvider));
795
+
796
+ export { AnythingQuickAccessProvider };