mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-18 23:59:43 +01:00
support multiple findTextInFiles filesToInclude (#225821)
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { AsyncIterableObject } from 'vs/base/common/async';
|
||||
import { CancellationTokenSource } from 'vs/base/common/cancellation';
|
||||
import * as errors from 'vs/base/common/errors';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
@@ -107,7 +106,6 @@ import { ExtensionDescriptionRegistry } from 'vs/workbench/services/extensions/c
|
||||
import { UIKind } from 'vs/workbench/services/extensions/common/extensionHostProtocol';
|
||||
import { checkProposedApiEnabled, isProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { ProxyIdentifier } from 'vs/workbench/services/extensions/common/proxyIdentifier';
|
||||
import { oldToNewTextSearchResult } from 'vs/workbench/services/search/common/searchExtConversionTypes';
|
||||
import { ExcludeSettingOptions, TextSearchCompleteMessageType, TextSearchContextNew, TextSearchMatchNew } from 'vs/workbench/services/search/common/searchExtTypes';
|
||||
import type * as vscode from 'vscode';
|
||||
|
||||
@@ -999,56 +997,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
||||
findTextInFilesNew: (query: vscode.TextSearchQueryNew, options?: vscode.FindTextInFilesOptionsNew, token?: vscode.CancellationToken): vscode.FindTextInFilesResponse => {
|
||||
checkProposedApiEnabled(extension, 'findTextInFilesNew');
|
||||
checkProposedApiEnabled(extension, 'textSearchProviderNew');
|
||||
let oldOptions = {};
|
||||
|
||||
|
||||
if (options) {
|
||||
oldOptions = {
|
||||
include: options.include && options.include.length > 0 ? options.include[0] : undefined,
|
||||
exclude: options.exclude && options.exclude.length > 0 ? options.exclude[0] : undefined,
|
||||
useDefaultExcludes: options.useExcludeSettings === undefined || (options.useExcludeSettings === ExcludeSettingOptions.FilesExclude || options.useExcludeSettings === ExcludeSettingOptions.SearchAndFilesExclude),
|
||||
useSearchExclude: options.useExcludeSettings === undefined || (options.useExcludeSettings === ExcludeSettingOptions.SearchAndFilesExclude),
|
||||
maxResults: options.maxResults,
|
||||
useIgnoreFiles: options.useIgnoreFiles?.local,
|
||||
useGlobalIgnoreFiles: options.useIgnoreFiles?.global,
|
||||
useParentIgnoreFiles: options.useIgnoreFiles?.parent,
|
||||
followSymlinks: options.followSymlinks,
|
||||
encoding: options.encoding,
|
||||
previewOptions: options.previewOptions ? {
|
||||
matchLines: options.previewOptions?.numMatchLines ?? 100,
|
||||
charsPerLine: options.previewOptions?.charsPerLine ?? 10000,
|
||||
} : undefined,
|
||||
beforeContext: options.surroundingContext,
|
||||
afterContext: options.surroundingContext,
|
||||
} satisfies vscode.FindTextInFilesOptions & { useSearchExclude?: boolean };
|
||||
}
|
||||
|
||||
const complete: Promise<undefined | vscode.TextSearchComplete> = Promise.resolve(undefined);
|
||||
|
||||
const asyncIterable = new AsyncIterableObject<vscode.TextSearchResultNew>(async emitter => {
|
||||
const callback = async (result: vscode.TextSearchResult) => {
|
||||
emitter.emitOne(oldToNewTextSearchResult(result));
|
||||
return result;
|
||||
};
|
||||
await complete.then(e => {
|
||||
return extHostWorkspace.findTextInFiles(
|
||||
query,
|
||||
oldOptions,
|
||||
callback,
|
||||
extension.identifier,
|
||||
token
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
results: asyncIterable,
|
||||
complete: complete.then((e) => {
|
||||
return {
|
||||
limitHit: e?.limitHit ?? false
|
||||
};
|
||||
}),
|
||||
};
|
||||
return extHostWorkspace.findTextInFilesNew(query, extension.identifier, options || {}, token);
|
||||
},
|
||||
save: (uri) => {
|
||||
return extHostWorkspace.save(uri);
|
||||
|
||||
Reference in New Issue
Block a user