101
});
102
}
104
>
// For each root folder'
105
>
106
>
// NEW: can just call with an array of folder info
107
>
this.doSearch(folderQueries, onResult).then(stats => {
108
>
resolve({
109
>
limitHit: this.isLimitHit,
110
>
stats: stats || undefined // Only looking at single-folder workspace stats...
111
>
});
112
>
}, (err: Error) => {
113
reject(new Error(toErrorMessage(err)));
115
>
});
116
>
}
117
118
119
private async doSearch(fqs: IFolderQuery<URI>[], onResult: (match: IInternalFileMatch) => void): Promise<IFileSearchProviderStats | null> {
121
>
const folderOptions = fqs.map(fq => this.getSearchOptionsForFolder(fq));
122
>
const session = this.provider instanceof OldFileSearchProviderConverter ? this.sessionLifecycle?.tokenSource.token : this.sessionLifecycle?.obj;
123
>
const options: FileSearchProviderOptions = {
124
>
folderOptions,
125
>
maxResults: this.config.maxResults ?? DEFAULT_MAX_SEARCH_RESULTS,
126
>
session
127
>
};
128
>
129
>
130
>
const getFolderQueryInfo = (fq: IFolderQuery) => {
131
const queryTester = new QueryGlobTester(this.config, fq);
132
const noSiblingsClauses = !queryTester.hasSiblingExcludeClauses();
133
return { queryTester, noSiblingsClauses, folder: fq.folder, tree: this.initDirectoryTree() };
134
};
136
>
const folderMappings: FolderQuerySearchTree<FolderQueryInfo> = new FolderQuerySearchTree<FolderQueryInfo>(fqs, getFolderQueryInfo);
137
>
138
>
let providerSW: StopWatch;
139
>
140
>
try {
141
>
this.activeCancellationTokens.add(cancellation);
142
>
143
>
providerSW = StopWatch.create();
144
>
const results = await this.provider.provideFileSearchResults(
145
>
this.config.filePattern || '',
146
>
options,
147
>
cancellation.token);
148
>
const providerTime = providerSW.elapsed();
149
>
const postProcessSW = StopWatch.create();
150
>
151
>
if (this.isCanceled && !this.isLimitHit) {
152
return null;
153
}