@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,416 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { coalesce, flatten, uniqueFilter } from 'vscode/vscode/vs/base/common/arrays';
3
+ import { raceCancellationError, DeferredPromise } from 'vscode/vscode/vs/base/common/async';
4
+ import { CancellationError } from 'vscode/vscode/vs/base/common/errors';
5
+ import { Disposable, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
6
+ import { ResourceMap, ResourceSet } from 'vscode/vscode/vs/base/common/map';
7
+ import { Schemas } from 'vscode/vscode/vs/base/common/network';
8
+ import { StopWatch } from 'vscode/vscode/vs/base/common/stopwatch';
9
+ import { isNumber } from 'vscode/vscode/vs/base/common/types';
10
+ import { IModelService } from 'vscode/vscode/vs/editor/common/services/model';
11
+ import { IFileService } from 'vscode/vscode/vs/platform/files/common/files';
12
+ import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
13
+ import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry';
14
+ import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity';
15
+ import { EditorResourceAccessor, SideBySideEditor } from 'vscode/vscode/vs/workbench/common/editor';
16
+ import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
17
+ import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions';
18
+ import { deserializeSearchError, SearchErrorCode, SEARCH_RESULT_LANGUAGE_ID, FileMatch, pathIncludedInQuery, isFileMatch, isProgressMessage } from 'vscode/vscode/vs/workbench/services/search/common/search';
19
+ import { editorMatchesToTextSearchResults, getTextSearchMatchWithModelContext } from 'vscode/vscode/vs/workbench/services/search/common/searchHelpers';
20
+
21
+ let SearchService = class SearchService extends Disposable {
22
+ constructor(modelService, editorService, telemetryService, logService, extensionService, fileService, uriIdentityService) {
23
+ super();
24
+ this.modelService = modelService;
25
+ this.editorService = editorService;
26
+ this.telemetryService = telemetryService;
27
+ this.logService = logService;
28
+ this.extensionService = extensionService;
29
+ this.fileService = fileService;
30
+ this.uriIdentityService = uriIdentityService;
31
+ this.fileSearchProviders = ( new Map());
32
+ this.textSearchProviders = ( new Map());
33
+ this.aiTextSearchProviders = ( new Map());
34
+ this.deferredFileSearchesByScheme = ( new Map());
35
+ this.deferredTextSearchesByScheme = ( new Map());
36
+ this.deferredAITextSearchesByScheme = ( new Map());
37
+ this.loggedSchemesMissingProviders = ( new Set());
38
+ }
39
+ registerSearchResultProvider(scheme, type, provider) {
40
+ let list;
41
+ let deferredMap;
42
+ if (type === 0 ) {
43
+ list = this.fileSearchProviders;
44
+ deferredMap = this.deferredFileSearchesByScheme;
45
+ }
46
+ else if (type === 1 ) {
47
+ list = this.textSearchProviders;
48
+ deferredMap = this.deferredTextSearchesByScheme;
49
+ }
50
+ else if (type === 2 ) {
51
+ list = this.aiTextSearchProviders;
52
+ deferredMap = this.deferredAITextSearchesByScheme;
53
+ }
54
+ else {
55
+ throw new Error('Unknown SearchProviderType');
56
+ }
57
+ list.set(scheme, provider);
58
+ if (( deferredMap.has(scheme))) {
59
+ deferredMap.get(scheme).complete(provider);
60
+ deferredMap.delete(scheme);
61
+ }
62
+ return toDisposable(() => {
63
+ list.delete(scheme);
64
+ });
65
+ }
66
+ async textSearch(query, token, onProgress) {
67
+ const results = this.textSearchSplitSyncAsync(query, token, onProgress);
68
+ const openEditorResults = results.syncResults;
69
+ const otherResults = await results.asyncResults;
70
+ return {
71
+ limitHit: otherResults.limitHit || openEditorResults.limitHit,
72
+ results: [...otherResults.results, ...openEditorResults.results],
73
+ messages: [...otherResults.messages, ...openEditorResults.messages]
74
+ };
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
+ }
92
+ textSearchSplitSyncAsync(query, token, onProgress, notebookFilesToIgnore, asyncNotebookFilesToIgnore) {
93
+ const openEditorResults = this.getOpenEditorResults(query);
94
+ if (onProgress) {
95
+ coalesce([...( openEditorResults.results.values())]).filter(e => !(notebookFilesToIgnore && ( notebookFilesToIgnore.has(e.resource)))).forEach(onProgress);
96
+ }
97
+ const syncResults = {
98
+ results: coalesce([...( openEditorResults.results.values())]),
99
+ limitHit: openEditorResults.limitHit ?? false,
100
+ messages: []
101
+ };
102
+ const getAsyncResults = async () => {
103
+ const resolvedAsyncNotebookFilesToIgnore = (await asyncNotebookFilesToIgnore) ?? ( new ResourceSet());
104
+ const onProviderProgress = (progress) => {
105
+ if (isFileMatch(progress)) {
106
+ if (!( openEditorResults.results.has(progress.resource)) && !( resolvedAsyncNotebookFilesToIgnore.has(progress.resource)) && onProgress) {
107
+ onProgress(progress);
108
+ }
109
+ }
110
+ else if (onProgress) {
111
+ onProgress(progress);
112
+ }
113
+ if (isProgressMessage(progress)) {
114
+ this.logService.debug('SearchService#search', progress.message);
115
+ }
116
+ };
117
+ return await this.doSearch(query, token, onProviderProgress);
118
+ };
119
+ return {
120
+ syncResults,
121
+ asyncResults: getAsyncResults()
122
+ };
123
+ }
124
+ fileSearch(query, token) {
125
+ return this.doSearch(query, token);
126
+ }
127
+ doSearch(query, token, onProgress) {
128
+ this.logService.trace('SearchService#search', JSON.stringify(query));
129
+ const schemesInQuery = this.getSchemesInQuery(query);
130
+ const providerActivations = [Promise.resolve(null)];
131
+ schemesInQuery.forEach(scheme => providerActivations.push(this.extensionService.activateByEvent(`onSearch:${scheme}`)));
132
+ providerActivations.push(this.extensionService.activateByEvent('onSearch:file'));
133
+ const providerPromise = (async () => {
134
+ await Promise.all(providerActivations);
135
+ await this.extensionService.whenInstalledExtensionsRegistered();
136
+ if (token && token.isCancellationRequested) {
137
+ return Promise.reject(( new CancellationError()));
138
+ }
139
+ const progressCallback = (item) => {
140
+ if (token && token.isCancellationRequested) {
141
+ return;
142
+ }
143
+ onProgress?.(item);
144
+ };
145
+ const exists = await Promise.all(( query.folderQueries.map(query => this.fileService.exists(query.folder))));
146
+ query.folderQueries = query.folderQueries.filter((_, i) => exists[i]);
147
+ let completes = await this.searchWithProviders(query, progressCallback, token);
148
+ completes = coalesce(completes);
149
+ if (!completes.length) {
150
+ return {
151
+ limitHit: false,
152
+ results: [],
153
+ messages: [],
154
+ };
155
+ }
156
+ return {
157
+ limitHit: completes[0] && completes[0].limitHit,
158
+ stats: completes[0].stats,
159
+ messages: coalesce(flatten(( completes.map(i => i.messages)))).filter(uniqueFilter(message => message.type + message.text + message.trusted)),
160
+ results: flatten(( completes.map((c) => c.results)))
161
+ };
162
+ })();
163
+ return token ? raceCancellationError(providerPromise, token) : providerPromise;
164
+ }
165
+ getSchemesInQuery(query) {
166
+ const schemes = ( new Set());
167
+ query.folderQueries?.forEach(fq => schemes.add(fq.folder.scheme));
168
+ query.extraFileResources?.forEach(extraFile => schemes.add(extraFile.scheme));
169
+ return schemes;
170
+ }
171
+ async waitForProvider(queryType, scheme) {
172
+ const deferredMap = this.getDeferredTextSearchesByScheme(queryType);
173
+ if (( deferredMap.has(scheme))) {
174
+ return deferredMap.get(scheme).p;
175
+ }
176
+ else {
177
+ const deferred = ( new DeferredPromise());
178
+ deferredMap.set(scheme, deferred);
179
+ return deferred.p;
180
+ }
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
+ }
206
+ async searchWithProviders(query, onProviderProgress, token) {
207
+ const e2eSW = StopWatch.create(false);
208
+ const searchPs = [];
209
+ const fqs = this.groupFolderQueriesByScheme(query);
210
+ const someSchemeHasProvider = ( [...( fqs.keys())].some(scheme => {
211
+ return ( this.getSearchProvider(query.type).has(scheme));
212
+ }));
213
+ if (query.type === 3 && !someSchemeHasProvider) {
214
+ return [];
215
+ }
216
+ await Promise.all(( [...( fqs.keys())].map(async (scheme) => {
217
+ const schemeFQs = fqs.get(scheme);
218
+ let provider = this.getSearchProvider(query.type).get(scheme);
219
+ if (!provider) {
220
+ if (someSchemeHasProvider) {
221
+ if (!( this.loggedSchemesMissingProviders.has(scheme))) {
222
+ this.logService.warn(`No search provider registered for scheme: ${scheme}. Another scheme has a provider, not waiting for ${scheme}`);
223
+ this.loggedSchemesMissingProviders.add(scheme);
224
+ }
225
+ return;
226
+ }
227
+ else {
228
+ if (!( this.loggedSchemesMissingProviders.has(scheme))) {
229
+ this.logService.warn(`No search provider registered for scheme: ${scheme}, waiting`);
230
+ this.loggedSchemesMissingProviders.add(scheme);
231
+ }
232
+ provider = await this.waitForProvider(query.type, scheme);
233
+ }
234
+ }
235
+ const oneSchemeQuery = {
236
+ ...query,
237
+ ...{
238
+ folderQueries: schemeFQs
239
+ }
240
+ };
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());
252
+ })));
253
+ return Promise.all(searchPs).then(completes => {
254
+ const endToEndTime = e2eSW.elapsed();
255
+ this.logService.trace(`SearchService#search: ${endToEndTime}ms`);
256
+ completes.forEach(complete => {
257
+ this.sendTelemetry(query, endToEndTime, complete);
258
+ });
259
+ return completes;
260
+ }, err => {
261
+ const endToEndTime = e2eSW.elapsed();
262
+ this.logService.trace(`SearchService#search: ${endToEndTime}ms`);
263
+ const searchError = deserializeSearchError(err);
264
+ this.logService.trace(`SearchService#searchError: ${searchError.message}`);
265
+ this.sendTelemetry(query, endToEndTime, undefined, searchError);
266
+ throw searchError;
267
+ });
268
+ }
269
+ groupFolderQueriesByScheme(query) {
270
+ const queries = ( new Map());
271
+ query.folderQueries.forEach(fq => {
272
+ const schemeFQs = queries.get(fq.folder.scheme) || [];
273
+ schemeFQs.push(fq);
274
+ queries.set(fq.folder.scheme, schemeFQs);
275
+ });
276
+ return queries;
277
+ }
278
+ sendTelemetry(query, endToEndTime, complete, err) {
279
+ const fileSchemeOnly = query.folderQueries.every(fq => fq.folder.scheme === Schemas.file);
280
+ const otherSchemeOnly = query.folderQueries.every(fq => fq.folder.scheme !== Schemas.file);
281
+ const scheme = fileSchemeOnly ? Schemas.file :
282
+ otherSchemeOnly ? 'other' :
283
+ 'mixed';
284
+ if (query.type === 1 && complete && complete.stats) {
285
+ const fileSearchStats = complete.stats;
286
+ if (fileSearchStats.fromCache) {
287
+ const cacheStats = fileSearchStats.detailStats;
288
+ this.telemetryService.publicLog2('cachedSearchComplete', {
289
+ reason: query._reason,
290
+ resultCount: fileSearchStats.resultCount,
291
+ workspaceFolderCount: query.folderQueries.length,
292
+ endToEndTime: endToEndTime,
293
+ sortingTime: fileSearchStats.sortingTime,
294
+ cacheWasResolved: cacheStats.cacheWasResolved,
295
+ cacheLookupTime: cacheStats.cacheLookupTime,
296
+ cacheFilterTime: cacheStats.cacheFilterTime,
297
+ cacheEntryCount: cacheStats.cacheEntryCount,
298
+ scheme
299
+ });
300
+ }
301
+ else {
302
+ const searchEngineStats = fileSearchStats.detailStats;
303
+ this.telemetryService.publicLog2('searchComplete', {
304
+ reason: query._reason,
305
+ resultCount: fileSearchStats.resultCount,
306
+ workspaceFolderCount: query.folderQueries.length,
307
+ endToEndTime: endToEndTime,
308
+ sortingTime: fileSearchStats.sortingTime,
309
+ fileWalkTime: searchEngineStats.fileWalkTime,
310
+ directoriesWalked: searchEngineStats.directoriesWalked,
311
+ filesWalked: searchEngineStats.filesWalked,
312
+ cmdTime: searchEngineStats.cmdTime,
313
+ cmdResultCount: searchEngineStats.cmdResultCount,
314
+ scheme
315
+ });
316
+ }
317
+ }
318
+ else if (query.type === 2 ) {
319
+ let errorType;
320
+ if (err) {
321
+ errorType = err.code === SearchErrorCode.regexParseError ? 'regex' :
322
+ err.code === SearchErrorCode.unknownEncoding ? 'encoding' :
323
+ err.code === SearchErrorCode.globParseError ? 'glob' :
324
+ err.code === SearchErrorCode.invalidLiteral ? 'literal' :
325
+ err.code === SearchErrorCode.other ? 'other' :
326
+ err.code === SearchErrorCode.canceled ? 'canceled' :
327
+ 'unknown';
328
+ }
329
+ this.telemetryService.publicLog2('textSearchComplete', {
330
+ reason: query._reason,
331
+ workspaceFolderCount: query.folderQueries.length,
332
+ endToEndTime: endToEndTime,
333
+ scheme,
334
+ error: errorType,
335
+ });
336
+ }
337
+ }
338
+ getOpenEditorResults(query) {
339
+ const openEditorResults = ( new ResourceMap(uri => this.uriIdentityService.extUri.getComparisonKey(uri)));
340
+ let limitHit = false;
341
+ if (query.type === 2 ) {
342
+ const canonicalToOriginalResources = ( new ResourceMap());
343
+ for (const editorInput of this.editorService.editors) {
344
+ const canonical = EditorResourceAccessor.getCanonicalUri(editorInput, { supportSideBySide: SideBySideEditor.PRIMARY });
345
+ const original = EditorResourceAccessor.getOriginalUri(editorInput, { supportSideBySide: SideBySideEditor.PRIMARY });
346
+ if (canonical) {
347
+ canonicalToOriginalResources.set(canonical, original ?? canonical);
348
+ }
349
+ }
350
+ const models = this.modelService.getModels();
351
+ models.forEach((model) => {
352
+ const resource = model.uri;
353
+ if (!resource) {
354
+ return;
355
+ }
356
+ if (limitHit) {
357
+ return;
358
+ }
359
+ const originalResource = canonicalToOriginalResources.get(resource);
360
+ if (!originalResource) {
361
+ return;
362
+ }
363
+ if (model.getLanguageId() === SEARCH_RESULT_LANGUAGE_ID && !(query.includePattern && query.includePattern['**/*.code-search'])) {
364
+ return;
365
+ }
366
+ if (originalResource.scheme !== Schemas.untitled && !this.fileService.hasProvider(originalResource)) {
367
+ return;
368
+ }
369
+ if (originalResource.scheme === 'git') {
370
+ return;
371
+ }
372
+ if (!this.matches(originalResource, query)) {
373
+ return;
374
+ }
375
+ const askMax = isNumber(query.maxResults) ? query.maxResults + 1 : Number.MAX_SAFE_INTEGER;
376
+ let matches = model.findMatches(query.contentPattern.pattern, false, !!query.contentPattern.isRegExp, !!query.contentPattern.isCaseSensitive, query.contentPattern.isWordMatch ? query.contentPattern.wordSeparators : null, false, askMax);
377
+ if (matches.length) {
378
+ if (askMax && matches.length >= askMax) {
379
+ limitHit = true;
380
+ matches = matches.slice(0, askMax - 1);
381
+ }
382
+ const fileMatch = ( new FileMatch(originalResource));
383
+ openEditorResults.set(originalResource, fileMatch);
384
+ const textSearchResults = editorMatchesToTextSearchResults(matches, model, query.previewOptions);
385
+ fileMatch.results = getTextSearchMatchWithModelContext(textSearchResults, model, query);
386
+ }
387
+ else {
388
+ openEditorResults.set(originalResource, null);
389
+ }
390
+ });
391
+ }
392
+ return {
393
+ results: openEditorResults,
394
+ limitHit
395
+ };
396
+ }
397
+ matches(resource, query) {
398
+ return pathIncludedInQuery(query, resource.fsPath);
399
+ }
400
+ async clearCache(cacheKey) {
401
+ const clearPs = ( Array.from(( this.fileSearchProviders.values()))
402
+ .map(provider => provider && provider.clearCache(cacheKey)));
403
+ await Promise.all(clearPs);
404
+ }
405
+ };
406
+ SearchService = ( __decorate([
407
+ ( __param(0, IModelService)),
408
+ ( __param(1, IEditorService)),
409
+ ( __param(2, ITelemetryService)),
410
+ ( __param(3, ILogService)),
411
+ ( __param(4, IExtensionService)),
412
+ ( __param(5, IFileService)),
413
+ ( __param(6, IUriIdentityService))
414
+ ], SearchService));
415
+
416
+ export { SearchService };