@codingame/monaco-vscode-search-service-override 8.0.4 → 9.0.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.
- package/package.json +2 -2
- package/vscode/src/vs/workbench/contrib/search/browser/patternInputWidget.js +3 -3
- package/vscode/src/vs/workbench/contrib/search/browser/quickTextSearch/textSearchQuickAccess.js +7 -7
- package/vscode/src/vs/workbench/contrib/search/browser/replaceService.js +2 -2
- package/vscode/src/vs/workbench/contrib/search/browser/search.contribution.js +80 -72
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsCopy.js +3 -3
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsNav.js +17 -17
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsRemoveReplace.js +4 -4
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsSymbol.js +3 -3
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsTextQuickAccess.js +1 -1
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsTopBar.js +8 -8
- package/vscode/src/vs/workbench/contrib/search/browser/searchFindInput.js +2 -2
- package/vscode/src/vs/workbench/contrib/search/browser/searchIcons.js +20 -20
- package/vscode/src/vs/workbench/contrib/search/browser/searchMessage.js +2 -2
- package/vscode/src/vs/workbench/contrib/search/browser/searchResultsView.js +14 -14
- package/vscode/src/vs/workbench/contrib/search/browser/searchView.js +58 -57
- package/vscode/src/vs/workbench/contrib/search/browser/searchWidget.js +8 -8
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditor.contribution.js +20 -20
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditor.js +23 -13
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditorActions.js +1 -1
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditorInput.js +4 -4
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditorSerialization.js +5 -5
- package/vscode/src/vs/workbench/services/search/browser/searchService.js +17 -16
- package/vscode/src/vs/workbench/services/search/common/getFileResults.js +9 -6
- package/vscode/src/vs/workbench/services/search/common/localFileSearchWorkerTypes.js +11 -0
- package/vscode/src/vs/workbench/services/search/common/searchService.js +3 -0
- package/vscode/src/vs/workbench/services/search/worker/localFileSearch.js +20 -17
|
@@ -119,8 +119,9 @@ let SearchEditor = class SearchEditor extends AbstractTextCodeEditor {
|
|
|
119
119
|
}
|
|
120
120
|
this._register(this.queryEditorWidget.onDidToggleContext(() => this.triggerSearch({ resetCursor: false })));
|
|
121
121
|
this.includesExcludesContainer = append(container, $('.includes-excludes'));
|
|
122
|
-
|
|
123
|
-
this.
|
|
122
|
+
const toggleQueryDetailsLabel = ( localize(8476, "Toggle Search Details"));
|
|
123
|
+
this.toggleQueryDetailsButton = append(this.includesExcludesContainer, $('.expand' + ThemeIcon.asCSSSelector(searchDetailsIcon), { tabindex: 0, role: 'button', 'aria-label': toggleQueryDetailsLabel }));
|
|
124
|
+
this._register(this.hoverService.setupManagedHover(getDefaultHoverDelegate('element'), this.toggleQueryDetailsButton, toggleQueryDetailsLabel));
|
|
124
125
|
this._register(addDisposableListener(this.toggleQueryDetailsButton, EventType.CLICK, e => {
|
|
125
126
|
EventHelper.stop(e);
|
|
126
127
|
this.toggleIncludesExcludes();
|
|
@@ -145,19 +146,19 @@ let SearchEditor = class SearchEditor extends AbstractTextCodeEditor {
|
|
|
145
146
|
}
|
|
146
147
|
}));
|
|
147
148
|
const folderIncludesList = append(this.includesExcludesContainer, $('.file-types.includes'));
|
|
148
|
-
const filesToIncludeTitle = ( localize(
|
|
149
|
+
const filesToIncludeTitle = ( localize(8477, "files to include"));
|
|
149
150
|
append(folderIncludesList, $('h4', undefined, filesToIncludeTitle));
|
|
150
151
|
this.inputPatternIncludes = this._register(scopedInstantiationService.createInstance(IncludePatternInputWidget, folderIncludesList, this.contextViewService, {
|
|
151
|
-
ariaLabel: ( localize(
|
|
152
|
+
ariaLabel: ( localize(8478, 'Search Include Patterns')),
|
|
152
153
|
inputBoxStyles: searchEditorInputboxStyles
|
|
153
154
|
}));
|
|
154
155
|
this.inputPatternIncludes.onSubmit(triggeredOnType => this.triggerSearch({ resetCursor: false, delay: triggeredOnType ? this.searchConfig.searchOnTypeDebouncePeriod : 0 }));
|
|
155
156
|
this._register(this.inputPatternIncludes.onChangeSearchInEditorsBox(() => this.triggerSearch()));
|
|
156
157
|
const excludesList = append(this.includesExcludesContainer, $('.file-types.excludes'));
|
|
157
|
-
const excludesTitle = ( localize(
|
|
158
|
+
const excludesTitle = ( localize(8479, "files to exclude"));
|
|
158
159
|
append(excludesList, $('h4', undefined, excludesTitle));
|
|
159
160
|
this.inputPatternExcludes = this._register(scopedInstantiationService.createInstance(ExcludePatternInputWidget, excludesList, this.contextViewService, {
|
|
160
|
-
ariaLabel: ( localize(
|
|
161
|
+
ariaLabel: ( localize(8480, 'Search Exclude Patterns')),
|
|
161
162
|
inputBoxStyles: searchEditorInputboxStyles
|
|
162
163
|
}));
|
|
163
164
|
this.inputPatternExcludes.onSubmit(triggeredOnType => this.triggerSearch({ resetCursor: false, delay: triggeredOnType ? this.searchConfig.searchOnTypeDebouncePeriod : 0 }));
|
|
@@ -176,7 +177,7 @@ let SearchEditor = class SearchEditor extends AbstractTextCodeEditor {
|
|
|
176
177
|
clearNode(this.messageBox);
|
|
177
178
|
this.messageDisposables.clear();
|
|
178
179
|
if (show) {
|
|
179
|
-
const runAgainLink = append(this.messageBox, $('a.pointer.prominent.message', {}, ( localize(
|
|
180
|
+
const runAgainLink = append(this.messageBox, $('a.pointer.prominent.message', {}, ( localize(8481, "Run Search"))));
|
|
180
181
|
this.messageDisposables.add(addDisposableListener(runAgainLink, EventType.CLICK, async () => {
|
|
181
182
|
await this.triggerSearch();
|
|
182
183
|
this.searchResultEditor.focus();
|
|
@@ -389,7 +390,7 @@ let SearchEditor = class SearchEditor extends AbstractTextCodeEditor {
|
|
|
389
390
|
}
|
|
390
391
|
}
|
|
391
392
|
alert(( localize(
|
|
392
|
-
|
|
393
|
+
8482,
|
|
393
394
|
"Matched {0} at {1} in file {2}",
|
|
394
395
|
matchText,
|
|
395
396
|
matchLineText,
|
|
@@ -413,7 +414,17 @@ let SearchEditor = class SearchEditor extends AbstractTextCodeEditor {
|
|
|
413
414
|
this.searchResultEditor.focus();
|
|
414
415
|
}
|
|
415
416
|
async triggerSearch(_options) {
|
|
417
|
+
const focusResults = this.searchConfig.searchEditor.focusResultsOnSearch;
|
|
418
|
+
if (_options === undefined) {
|
|
419
|
+
_options = { focusResults: focusResults };
|
|
420
|
+
}
|
|
421
|
+
else if (_options.focusResults === undefined) {
|
|
422
|
+
_options.focusResults = focusResults;
|
|
423
|
+
}
|
|
416
424
|
const options = { resetCursor: true, delay: 0, ..._options };
|
|
425
|
+
if (!(this.queryEditorWidget.searchInput?.inputBox.isInputValid())) {
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
417
428
|
if (!this.pauseSearching) {
|
|
418
429
|
await this.runSearchDelayer.trigger(async () => {
|
|
419
430
|
this.toggleRunAgainMessage(false);
|
|
@@ -475,15 +486,14 @@ let SearchEditor = class SearchEditor extends AbstractTextCodeEditor {
|
|
|
475
486
|
maxResults: this.searchConfig.maxResults ?? undefined,
|
|
476
487
|
disregardIgnoreFiles: !config.useExcludeSettingsAndIgnoreFiles || undefined,
|
|
477
488
|
disregardExcludeSettings: !config.useExcludeSettingsAndIgnoreFiles || undefined,
|
|
478
|
-
excludePattern: config.filesToExclude,
|
|
489
|
+
excludePattern: [{ pattern: config.filesToExclude }],
|
|
479
490
|
includePattern: config.filesToInclude,
|
|
480
491
|
onlyOpenEditors: config.onlyOpenEditors,
|
|
481
492
|
previewOptions: {
|
|
482
493
|
matchLines: 1,
|
|
483
494
|
charsPerLine: 1000
|
|
484
495
|
},
|
|
485
|
-
|
|
486
|
-
beforeContext: config.contextLines,
|
|
496
|
+
surroundingContext: config.contextLines,
|
|
487
497
|
isSmartCase: this.searchConfig.smartCase,
|
|
488
498
|
expandPatterns: true,
|
|
489
499
|
notebookSearchConfig: {
|
|
@@ -687,7 +697,7 @@ let SearchEditor = class SearchEditor extends AbstractTextCodeEditor {
|
|
|
687
697
|
}
|
|
688
698
|
}
|
|
689
699
|
getAriaLabel() {
|
|
690
|
-
return this.getInput()?.getName() ?? ( localize(
|
|
700
|
+
return this.getInput()?.getName() ?? ( localize(8483, "Search"));
|
|
691
701
|
}
|
|
692
702
|
};
|
|
693
703
|
SearchEditor = SearchEditor_1 = ( (__decorate([
|
|
@@ -711,7 +721,7 @@ SearchEditor = SearchEditor_1 = ( (__decorate([
|
|
|
711
721
|
( (__param(18, ILogService))),
|
|
712
722
|
( (__param(19, IHoverService)))
|
|
713
723
|
], SearchEditor)));
|
|
714
|
-
const searchEditorTextInputBorder = registerColor('searchEditor.textInputBorder', inputBorder, ( localize(
|
|
724
|
+
const searchEditorTextInputBorder = registerColor('searchEditor.textInputBorder', inputBorder, ( localize(8484, "Search editor text input box border.")));
|
|
715
725
|
function findNextRange(matchRanges, currentPosition) {
|
|
716
726
|
for (const matchRange of matchRanges) {
|
|
717
727
|
if (Position.isBefore(currentPosition, matchRange.getStartPosition())) {
|
|
@@ -184,7 +184,7 @@ const createEditorFromSearchResult = async (accessor, searchResult, rawIncludePa
|
|
|
184
184
|
else {
|
|
185
185
|
const input = instantiationService.invokeFunction(getOrMakeSearchEditorInput, { from: 'rawData', resultsContents: '', config: { ...config, contextLines } });
|
|
186
186
|
const editor = await editorService.openEditor(input, { pinned: true });
|
|
187
|
-
editor.triggerSearch(
|
|
187
|
+
editor.triggerSearch();
|
|
188
188
|
}
|
|
189
189
|
};
|
|
190
190
|
|
|
@@ -29,7 +29,7 @@ import { registerIcon } from 'vscode/vscode/vs/platform/theme/common/iconRegistr
|
|
|
29
29
|
|
|
30
30
|
var SearchEditorInput_1;
|
|
31
31
|
const SEARCH_EDITOR_EXT = '.code-search';
|
|
32
|
-
const SearchEditorIcon = registerIcon('search-editor-label-icon', Codicon.search, ( localize(
|
|
32
|
+
const SearchEditorIcon = registerIcon('search-editor-label-icon', Codicon.search, ( localize(8485, 'Icon of the search editor label.')));
|
|
33
33
|
let SearchEditorInput = class SearchEditorInput extends EditorInput {
|
|
34
34
|
static { SearchEditorInput_1 = this; }
|
|
35
35
|
static { this.ID = SearchEditorInputTypeId; }
|
|
@@ -162,16 +162,16 @@ let SearchEditorInput = class SearchEditorInput extends EditorInput {
|
|
|
162
162
|
if (this.backingUri) {
|
|
163
163
|
const originalURI = EditorResourceAccessor.getOriginalUri(this);
|
|
164
164
|
return ( localize(
|
|
165
|
-
|
|
165
|
+
8486,
|
|
166
166
|
"Search: {0}",
|
|
167
167
|
basename((originalURI ?? this.backingUri).path, SEARCH_EDITOR_EXT)
|
|
168
168
|
));
|
|
169
169
|
}
|
|
170
170
|
const query = this._cachedConfigurationModel?.config?.query?.trim();
|
|
171
171
|
if (query) {
|
|
172
|
-
return ( localize(
|
|
172
|
+
return ( localize(8486, "Search: {0}", trimToMax(query)));
|
|
173
173
|
}
|
|
174
|
-
return ( localize(
|
|
174
|
+
return ( localize(8487, "Search"));
|
|
175
175
|
}
|
|
176
176
|
setDirty(dirty) {
|
|
177
177
|
const wasDirty = this.dirty;
|
|
@@ -164,7 +164,7 @@ const extractSearchQueryFromLines = (lines) => {
|
|
|
164
164
|
out += '\\';
|
|
165
165
|
}
|
|
166
166
|
else {
|
|
167
|
-
throw Error(localize(
|
|
167
|
+
throw Error(localize(10848, "All backslashes in Query string must be escaped (\\\\)"));
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
else {
|
|
@@ -210,16 +210,16 @@ const serializeSearchResultForEditor = (searchResult, rawIncludePattern, rawExcl
|
|
|
210
210
|
throw Error('Internal Error: Expected query, got null');
|
|
211
211
|
}
|
|
212
212
|
const config = contentPatternToSearchConfiguration(searchResult.query, rawIncludePattern, rawExcludePattern, contextLines);
|
|
213
|
-
const filecount = searchResult.fileCount() > 1 ? ( localize(
|
|
214
|
-
const resultcount = searchResult.count() > 1 ? ( localize(
|
|
213
|
+
const filecount = searchResult.fileCount() > 1 ? ( localize(10849, "{0} files", searchResult.fileCount())) : ( localize(10850, "1 file"));
|
|
214
|
+
const resultcount = searchResult.count() > 1 ? ( localize(10851, "{0} results", searchResult.count())) : ( localize(10852, "1 result"));
|
|
215
215
|
const info = [
|
|
216
216
|
searchResult.count()
|
|
217
217
|
? `${resultcount} - ${filecount}`
|
|
218
|
-
: ( localize(
|
|
218
|
+
: ( localize(10853, "No Results")),
|
|
219
219
|
];
|
|
220
220
|
if (limitHit) {
|
|
221
221
|
info.push(( localize(
|
|
222
|
-
|
|
222
|
+
10854,
|
|
223
223
|
"The result set only contains a subset of all matches. Be more specific in your search to narrow down the results."
|
|
224
224
|
)));
|
|
225
225
|
}
|
|
@@ -4,10 +4,11 @@ import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.servi
|
|
|
4
4
|
import 'vscode/vscode/vs/workbench/services/search/common/search';
|
|
5
5
|
import '../common/searchService.js';
|
|
6
6
|
import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
|
|
7
|
-
import {
|
|
7
|
+
import { logOnceWebWorkerWarning } from 'vscode/vscode/vs/base/common/worker/simpleWorker';
|
|
8
8
|
import { Disposable, DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
9
|
-
import {
|
|
9
|
+
import { createWebWorker } from 'vscode/vscode/vs/base/browser/defaultWorkerFactory';
|
|
10
10
|
import 'vscode/vscode/vs/platform/instantiation/common/extensions';
|
|
11
|
+
import { LocalFileSearchSimpleWorkerHost } from '../common/localFileSearchWorkerTypes.js';
|
|
11
12
|
import { memoize } from 'vscode/vscode/vs/base/common/decorators';
|
|
12
13
|
import { Schemas } from 'vscode/vscode/vs/base/common/network';
|
|
13
14
|
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
@@ -26,7 +27,6 @@ let LocalFileSearchWorkerClient = class LocalFileSearchWorkerClient extends Disp
|
|
|
26
27
|
this.onDidReceiveTextSearchMatch = this._onDidReceiveTextSearchMatch.event;
|
|
27
28
|
this.queryId = 0;
|
|
28
29
|
this._worker = null;
|
|
29
|
-
this._workerFactory = ( (new DefaultWorkerFactory('localFileSearchWorker')));
|
|
30
30
|
}
|
|
31
31
|
sendTextSearchMatch(match, queryId) {
|
|
32
32
|
this._onDidReceiveTextSearchMatch.fire({ match, queryId });
|
|
@@ -35,13 +35,13 @@ let LocalFileSearchWorkerClient = class LocalFileSearchWorkerClient extends Disp
|
|
|
35
35
|
return this.fileService.getProvider(Schemas.file);
|
|
36
36
|
}
|
|
37
37
|
async cancelQuery(queryId) {
|
|
38
|
-
const proxy =
|
|
39
|
-
proxy
|
|
38
|
+
const proxy = this._getOrCreateWorker().proxy;
|
|
39
|
+
proxy.$cancelQuery(queryId);
|
|
40
40
|
}
|
|
41
41
|
async textSearch(query, onProgress, token) {
|
|
42
42
|
try {
|
|
43
43
|
const queryDisposables = ( (new DisposableStore()));
|
|
44
|
-
const proxy =
|
|
44
|
+
const proxy = this._getOrCreateWorker().proxy;
|
|
45
45
|
const results = [];
|
|
46
46
|
let limitHit = false;
|
|
47
47
|
await Promise.all(( (query.folderQueries.map(async (fq) => {
|
|
@@ -62,7 +62,7 @@ let LocalFileSearchWorkerClient = class LocalFileSearchWorkerClient extends Disp
|
|
|
62
62
|
}
|
|
63
63
|
}));
|
|
64
64
|
const ignorePathCasing = this.uriIdentityService.extUri.ignorePathCasing(fq.folder);
|
|
65
|
-
const folderResults = await proxy
|
|
65
|
+
const folderResults = await proxy.$searchDirectory(handle, query, fq, ignorePathCasing, queryId);
|
|
66
66
|
for (const folderResult of folderResults.results) {
|
|
67
67
|
results.push(revive(folderResult));
|
|
68
68
|
}
|
|
@@ -79,7 +79,7 @@ let LocalFileSearchWorkerClient = class LocalFileSearchWorkerClient extends Disp
|
|
|
79
79
|
return {
|
|
80
80
|
results: [],
|
|
81
81
|
messages: [{
|
|
82
|
-
text: ( localize(
|
|
82
|
+
text: ( localize(3366, "Unable to search with Web Worker text searcher")), type: TextSearchCompleteMessageType.Warning
|
|
83
83
|
}],
|
|
84
84
|
};
|
|
85
85
|
}
|
|
@@ -88,7 +88,7 @@ let LocalFileSearchWorkerClient = class LocalFileSearchWorkerClient extends Disp
|
|
|
88
88
|
try {
|
|
89
89
|
const queryDisposables = ( (new DisposableStore()));
|
|
90
90
|
let limitHit = false;
|
|
91
|
-
const proxy =
|
|
91
|
+
const proxy = this._getOrCreateWorker().proxy;
|
|
92
92
|
const results = [];
|
|
93
93
|
await Promise.all(( (query.folderQueries.map(async (fq) => {
|
|
94
94
|
const queryId = this.queryId++;
|
|
@@ -99,7 +99,7 @@ let LocalFileSearchWorkerClient = class LocalFileSearchWorkerClient extends Disp
|
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
101
101
|
const caseSensitive = this.uriIdentityService.extUri.ignorePathCasing(fq.folder);
|
|
102
|
-
const folderResults = await proxy
|
|
102
|
+
const folderResults = await proxy.$listDirectory(handle, query, fq, caseSensitive, queryId);
|
|
103
103
|
for (const folderResult of folderResults.results) {
|
|
104
104
|
results.push({ resource: URI.joinPath(fq.folder, folderResult) });
|
|
105
105
|
}
|
|
@@ -116,7 +116,7 @@ let LocalFileSearchWorkerClient = class LocalFileSearchWorkerClient extends Disp
|
|
|
116
116
|
return {
|
|
117
117
|
results: [],
|
|
118
118
|
messages: [{
|
|
119
|
-
text: ( localize(
|
|
119
|
+
text: ( localize(3367, "Unable to search with Web Worker file searcher")), type: TextSearchCompleteMessageType.Warning
|
|
120
120
|
}],
|
|
121
121
|
};
|
|
122
122
|
}
|
|
@@ -129,11 +129,12 @@ let LocalFileSearchWorkerClient = class LocalFileSearchWorkerClient extends Disp
|
|
|
129
129
|
_getOrCreateWorker() {
|
|
130
130
|
if (!this._worker) {
|
|
131
131
|
try {
|
|
132
|
-
this._worker = this._register((
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
132
|
+
this._worker = this._register(createWebWorker('vs/workbench/services/search/worker/localFileSearch', 'LocalFileSearchWorker'));
|
|
133
|
+
LocalFileSearchSimpleWorkerHost.setChannel(this._worker, {
|
|
134
|
+
$sendTextSearchMatch: (match, queryId) => {
|
|
135
|
+
return this.sendTextSearchMatch(match, queryId);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
137
138
|
}
|
|
138
139
|
catch (err) {
|
|
139
140
|
logOnceWebWorkerWarning(err);
|
|
@@ -49,8 +49,8 @@ const getFileResults = (bytes, pattern, options) => {
|
|
|
49
49
|
while (Boolean(lineRanges[endLine + 1]) && matchStartIndex + matchedText.length > lineRanges[endLine].end) {
|
|
50
50
|
endLine++;
|
|
51
51
|
}
|
|
52
|
-
if (options.
|
|
53
|
-
for (let contextLine = Math.max(0, startLine - options.
|
|
52
|
+
if (options.surroundingContext) {
|
|
53
|
+
for (let contextLine = Math.max(0, startLine - options.surroundingContext); contextLine < startLine; contextLine++) {
|
|
54
54
|
contextLinesNeeded.add(contextLine);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -78,12 +78,15 @@ const getFileResults = (bytes, pattern, options) => {
|
|
|
78
78
|
matchStartIndex + matchedText.length - lineRanges[endLine].start - (endLine === startLine ? offset : 0)
|
|
79
79
|
));
|
|
80
80
|
const match = {
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
rangeLocations: [{
|
|
82
|
+
source: fileRange,
|
|
83
|
+
preview: previewRange,
|
|
84
|
+
}],
|
|
85
|
+
previewText: previewText
|
|
83
86
|
};
|
|
84
87
|
results.push(match);
|
|
85
|
-
if (options.
|
|
86
|
-
for (let contextLine = endLine + 1; contextLine <= Math.min(endLine + options.
|
|
88
|
+
if (options.surroundingContext) {
|
|
89
|
+
for (let contextLine = endLine + 1; contextLine <= Math.min(endLine + options.surroundingContext, lineRanges.length - 1); contextLine++) {
|
|
87
90
|
contextLinesNeeded.add(contextLine);
|
|
88
91
|
}
|
|
89
92
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
class LocalFileSearchSimpleWorkerHost {
|
|
2
|
+
static { this.CHANNEL_NAME = 'localFileSearchWorkerHost'; }
|
|
3
|
+
static getChannel(workerServer) {
|
|
4
|
+
return workerServer.getChannel(LocalFileSearchSimpleWorkerHost.CHANNEL_NAME);
|
|
5
|
+
}
|
|
6
|
+
static setChannel(workerClient, obj) {
|
|
7
|
+
workerClient.setChannel(LocalFileSearchSimpleWorkerHost.CHANNEL_NAME, obj);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { LocalFileSearchSimpleWorkerHost };
|
|
@@ -214,6 +214,9 @@ let SearchService = class SearchService extends Disposable {
|
|
|
214
214
|
return [];
|
|
215
215
|
}
|
|
216
216
|
await Promise.all(( [...( fqs.keys())].map(async (scheme) => {
|
|
217
|
+
if (query.onlyFileScheme && scheme !== Schemas.file) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
217
220
|
const schemeFQs = fqs.get(scheme);
|
|
218
221
|
let provider = this.getSearchProvider(query.type).get(scheme);
|
|
219
222
|
if (!provider) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { parse, match } from 'vscode/vscode/vs/base/common/glob';
|
|
2
2
|
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
3
|
+
import { LocalFileSearchSimpleWorkerHost } from '../common/localFileSearchWorkerTypes.js';
|
|
3
4
|
import { relative } from 'vscode/vscode/vs/base/common/path';
|
|
4
5
|
import { CancellationTokenSource } from 'vscode/vscode/vs/base/common/cancellation';
|
|
5
6
|
import { getFileResults } from '../common/getFileResults.js';
|
|
@@ -7,21 +8,22 @@ import { IgnoreFile } from 'vscode/vscode/vs/workbench/services/search/common/ig
|
|
|
7
8
|
import { createRegExp } from 'vscode/vscode/vs/base/common/strings';
|
|
8
9
|
import { Promises } from 'vscode/vscode/vs/base/common/async';
|
|
9
10
|
import { ExtUri } from 'vscode/vscode/vs/base/common/resources';
|
|
11
|
+
import { revive } from 'vscode/vscode/vs/base/common/marshalling';
|
|
10
12
|
|
|
11
13
|
const time = async (name, task) => {
|
|
12
14
|
{
|
|
13
15
|
return task();
|
|
14
16
|
}
|
|
15
17
|
};
|
|
16
|
-
function create(
|
|
17
|
-
return ( new LocalFileSearchSimpleWorker(
|
|
18
|
+
function create(workerServer) {
|
|
19
|
+
return ( new LocalFileSearchSimpleWorker(workerServer));
|
|
18
20
|
}
|
|
19
21
|
class LocalFileSearchSimpleWorker {
|
|
20
|
-
constructor(
|
|
21
|
-
this.host = host;
|
|
22
|
+
constructor(workerServer) {
|
|
22
23
|
this.cancellationTokens = ( new Map());
|
|
24
|
+
this.host = LocalFileSearchSimpleWorkerHost.getChannel(workerServer);
|
|
23
25
|
}
|
|
24
|
-
cancelQuery(queryId) {
|
|
26
|
+
$cancelQuery(queryId) {
|
|
25
27
|
this.cancellationTokens.get(queryId)?.cancel();
|
|
26
28
|
}
|
|
27
29
|
registerCancellationToken(queryId) {
|
|
@@ -29,7 +31,7 @@ class LocalFileSearchSimpleWorker {
|
|
|
29
31
|
this.cancellationTokens.set(queryId, source);
|
|
30
32
|
return source;
|
|
31
33
|
}
|
|
32
|
-
async listDirectory(handle, query, folderQuery, ignorePathCasing, queryId) {
|
|
34
|
+
async $listDirectory(handle, query, folderQuery, ignorePathCasing, queryId) {
|
|
33
35
|
const revivedFolderQuery = reviveFolderQuery(folderQuery);
|
|
34
36
|
const extUri = ( new ExtUri(() => ignorePathCasing));
|
|
35
37
|
const token = this.registerCancellationToken(queryId);
|
|
@@ -56,7 +58,7 @@ class LocalFileSearchSimpleWorker {
|
|
|
56
58
|
limitHit
|
|
57
59
|
};
|
|
58
60
|
}
|
|
59
|
-
async searchDirectory(handle, query, folderQuery, ignorePathCasing, queryId) {
|
|
61
|
+
async $searchDirectory(handle, query, folderQuery, ignorePathCasing, queryId) {
|
|
60
62
|
const revivedQuery = reviveFolderQuery(folderQuery);
|
|
61
63
|
const extUri = ( new ExtUri(() => ignorePathCasing));
|
|
62
64
|
return time('searchInFiles', async () => {
|
|
@@ -76,8 +78,7 @@ class LocalFileSearchSimpleWorker {
|
|
|
76
78
|
}
|
|
77
79
|
const bytes = ( new Uint8Array(contents));
|
|
78
80
|
const fileResults = getFileResults(bytes, pattern, {
|
|
79
|
-
|
|
80
|
-
beforeContext: query.beforeContext ?? 0,
|
|
81
|
+
surroundingContext: query.surroundingContext ?? 0,
|
|
81
82
|
previewOptions: query.previewOptions,
|
|
82
83
|
remainingResultQuota: query.maxResults ? (query.maxResults - resultCount) : 10000,
|
|
83
84
|
});
|
|
@@ -90,7 +91,7 @@ class LocalFileSearchSimpleWorker {
|
|
|
90
91
|
resource: URI.joinPath(revivedQuery.folder, file.path),
|
|
91
92
|
results: fileResults,
|
|
92
93
|
};
|
|
93
|
-
this.host
|
|
94
|
+
this.host.$sendTextSearchMatch(match, queryId);
|
|
94
95
|
results.push(match);
|
|
95
96
|
}
|
|
96
97
|
};
|
|
@@ -103,10 +104,15 @@ class LocalFileSearchSimpleWorker {
|
|
|
103
104
|
});
|
|
104
105
|
}
|
|
105
106
|
async walkFolderQuery(handle, queryProps, folderQuery, extUri, onFile, token) {
|
|
106
|
-
const folderExcludes =
|
|
107
|
+
const folderExcludes = folderQuery.excludePattern?.map(excludePattern => parse(excludePattern.pattern ?? {}, { trimForExclusions: true }));
|
|
108
|
+
const evalFolderExcludes = (path, basename, hasSibling) => {
|
|
109
|
+
return folderExcludes?.some(folderExclude => {
|
|
110
|
+
return folderExclude(path, basename, hasSibling);
|
|
111
|
+
});
|
|
112
|
+
};
|
|
107
113
|
const isFolderExcluded = (path, basename, hasSibling) => {
|
|
108
114
|
path = path.slice(1);
|
|
109
|
-
if (
|
|
115
|
+
if (evalFolderExcludes(path, basename, hasSibling)) {
|
|
110
116
|
return true;
|
|
111
117
|
}
|
|
112
118
|
if (pathExcludedInQuery(queryProps, path)) {
|
|
@@ -116,7 +122,7 @@ class LocalFileSearchSimpleWorker {
|
|
|
116
122
|
};
|
|
117
123
|
const isFileIncluded = (path, basename, hasSibling) => {
|
|
118
124
|
path = path.slice(1);
|
|
119
|
-
if (
|
|
125
|
+
if (evalFolderExcludes(path, basename, hasSibling)) {
|
|
120
126
|
return false;
|
|
121
127
|
}
|
|
122
128
|
if (!pathIncludedInQuery(queryProps, path, extUri)) {
|
|
@@ -215,10 +221,7 @@ function createSearchRegExp(options) {
|
|
|
215
221
|
});
|
|
216
222
|
}
|
|
217
223
|
function reviveFolderQuery(folderQuery) {
|
|
218
|
-
return
|
|
219
|
-
...folderQuery,
|
|
220
|
-
folder: URI.revive(folderQuery.folder),
|
|
221
|
-
};
|
|
224
|
+
return revive(folderQuery);
|
|
222
225
|
}
|
|
223
226
|
function reviveQueryProps(queryProps) {
|
|
224
227
|
return {
|