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