diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index 60c35821086..d3c2ab00b46 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -976,8 +976,8 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I const oldOptions = { exclude: options?.exclude && options.exclude.length > 0 ? options.exclude[0] : undefined, - useDefaultExcludes: !options?.useExcludeSettings || (options?.useExcludeSettings === ExcludeSettingOptions.filesExclude || options?.useExcludeSettings === ExcludeSettingOptions.searchAndFilesExclude), - useDefaultSearchExcludes: !options?.useExcludeSettings || (options?.useExcludeSettings === ExcludeSettingOptions.searchAndFilesExclude), + useDefaultExcludes: !options?.useExcludeSettings || (options?.useExcludeSettings === ExcludeSettingOptions.FilesExclude || options?.useExcludeSettings === ExcludeSettingOptions.SearchAndFilesExclude), + useDefaultSearchExcludes: !options?.useExcludeSettings || (options?.useExcludeSettings === ExcludeSettingOptions.SearchAndFilesExclude), maxResults: options?.maxResults, useIgnoreFiles: options?.useIgnoreFiles?.local, useGlobalIgnoreFiles: options?.useIgnoreFiles?.global, @@ -1012,8 +1012,8 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I 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), + 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, @@ -1021,7 +1021,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I followSymlinks: options.followSymlinks, encoding: options.encoding, previewOptions: options.previewOptions ? { - matchLines: options.previewOptions?.matchLines ?? 100, + matchLines: options.previewOptions?.numMatchLines ?? 100, charsPerLine: options.previewOptions?.charsPerLine ?? 10000, } : undefined, beforeContext: options.surroundingContext, diff --git a/src/vs/workbench/services/search/common/searchExtTypes.ts b/src/vs/workbench/services/search/common/searchExtTypes.ts index cece6091496..dde9bee1782 100644 --- a/src/vs/workbench/services/search/common/searchExtTypes.ts +++ b/src/vs/workbench/services/search/common/searchExtTypes.ts @@ -538,22 +538,25 @@ export class TextSearchContextNew { public lineNumber: number) { } } +/** + * Options for following search.exclude and files.exclude settings. + */ export enum ExcludeSettingOptions { /* * Don't use any exclude settings. */ - none = 1, + None = 1, /* * Use: * - files.exclude setting */ - filesExclude = 2, + FilesExclude = 2, /* * Use: * - files.exclude setting * - search.exclude setting */ - searchAndFilesExclude = 3 + SearchAndFilesExclude = 3 } export enum TextSearchCompleteMessageTypeNew { diff --git a/src/vscode-dts/vscode.proposed.findFiles2New.d.ts b/src/vscode-dts/vscode.proposed.findFiles2New.d.ts index 610687aa016..5ccc4e1bc32 100644 --- a/src/vscode-dts/vscode.proposed.findFiles2New.d.ts +++ b/src/vscode-dts/vscode.proposed.findFiles2New.d.ts @@ -7,8 +7,19 @@ declare module 'vscode' { export interface FindFiles2OptionsNew { /** - * A {@link GlobPattern glob pattern} that defines files and folders to exclude. The glob pattern - * will be matched against the file paths of resulting matches relative to their workspace. + * An array of {@link GlobPattern GlobPattern} that defines files to exclude. + * The glob patterns will be matched against the file paths of files relative to their workspace or {@link RelativePattern.baseUri} if applicable. + * + * If more than one value is used, the values are combined with a logical AND. + * For example, consider the following code: + * + * ```ts + * const ab = findFiles(['**​/*.js'], {exclude: ['*.ts', '*.js']}); + * const a = findFiles(['**​/*.js'], {exclude: ['*.ts']}); + * const b = findFiles(['**​/*.js'], {exclude: ['*.js']}); + * ``` + * + * In this, `ab` will be the intersection of results from `a` and `b`. */ exclude?: GlobPattern[]; @@ -18,19 +29,21 @@ declare module 'vscode' { useExcludeSettings?: ExcludeSettingOptions; /** - * The maximum number of results to search for + * The maximum number of results to search for. Defaults to 20000 results. */ maxResults?: number; /** - * Which file locations we should look for ignore (.gitignore or .ignore) files to respect. + * Which file locations have ignore (`.gitignore` or `.ignore`) files to follow. * - * When any of these fields are `undefined`, we will: - * - assume the value if possible (e.g. if only one is valid) - * or - * - follow settings using the value for the corresponding `search.use*IgnoreFiles` settting. + * When any of these fields are `undefined`, the value will either be assumed (e.g. if only one is valid), + * or it will follow settings based on the corresponding `search.use*IgnoreFiles` setting. * * Will log an error if an invalid combination is set. + * + * Although `.ignore` files are uncommon, they can be leveraged if there are patterns + * that should not be known to git, but should be known to the search providers. + * They should be in the same locations where `.gitignore` files are found, and they follow the same format. */ useIgnoreFiles?: { /** @@ -67,9 +80,21 @@ declare module 'vscode' { * @example * findFiles(['**​/*.js'], {exclude: ['**​/out/**'], useIgnoreFiles: true, maxResults: 10}) * - * @param filePattern A {@link GlobPattern glob pattern} that defines the files to search for. The glob pattern - * will be matched against the file paths of resulting matches relative to their workspace. Use a {@link RelativePattern relative pattern} - * to restrict the search results to a {@link WorkspaceFolder workspace folder}. + * @param filePattern An array of {@link GlobPattern GlobPattern} that defines the files to search for. + * The glob patterns will be matched against the file paths of files relative to their workspace or {@link baseUri GlobPattern.baseUri} if applicable. + * Use a {@link RelativePattern RelativePatten} to restrict the search results to a {@link WorkspaceFolder workspace folder}. + * + * If more than one value is used, the values are combined with a logical OR. + * + * For example, consider the following code: + * + * ```ts + * const ab = findFiles(['*.ts', '*.js']); + * const a = findFiles(['**​/*.ts']); + * const b = findFiles(['**​/*.js']); + * ``` + * + * In this, `ab` will be the union of results from `a` and `b`. * @param options A set of {@link FindFiles2Options FindFiles2Options} that defines where and how to search (e.g. exclude settings). * @param token A token that can be used to signal cancellation to the underlying search engine. * @returns A thenable that resolves to an array of resource identifiers. Will return no results if no diff --git a/src/vscode-dts/vscode.proposed.findTextInFilesNew.d.ts b/src/vscode-dts/vscode.proposed.findTextInFilesNew.d.ts index 928291faaaa..12c03c71deb 100644 --- a/src/vscode-dts/vscode.proposed.findTextInFilesNew.d.ts +++ b/src/vscode-dts/vscode.proposed.findTextInFilesNew.d.ts @@ -9,15 +9,38 @@ declare module 'vscode' { export interface FindTextInFilesOptionsNew { /** - * A {@link GlobPattern glob pattern} that defines the files to search for. The glob pattern - * will be matched against the file paths of files relative to their workspace. Use a {@link RelativePattern relative pattern} - * to restrict the search results to a {@link WorkspaceFolder workspace folder}. + * An array of {@link GlobPattern GlobPattern} that defines the files to search for. + * The glob patterns will be matched against the file paths of files relative to their workspace or {@link baseUri GlobPattern.baseUri} if applicable. + * Use a {@link RelativePattern RelativePattern} to restrict the search results to a {@link WorkspaceFolder workspace folder}. + * + * If more than one value is used, the values are combined with a logical OR. + * + * For example, consider the following code: + * + * ```ts + * const ab = findTextInFilesNew('foo', {include: ['*.ts', '*.js']}); + * const a = findTextInFilesNew('foo', {include: ['*.ts']}); + * const b = findTextInFilesNew('foo', {include: ['*.js']}); + * ``` + * + * In this, `ab` will be the union of results from `a` and `b`. */ include?: GlobPattern[]; /** - * A {@link GlobPattern glob pattern} that defines files and folders to exclude. The glob pattern - * will be matched against the file paths of resulting matches relative to their workspace. + * An array of {@link GlobPattern GlobPattern} that defines files to exclude. + * The glob patterns will be matched against the file paths of files relative to their workspace or {@link RelativePattern.baseUri} if applicable. + * + * If more than one value is used, the values are combined with a logical AND. + * For example, consider the following code: + * + * ```ts + * const ab = findTextInFilesNew('foo', {exclude: ['*.ts', '*.js']}); + * const a = findTextInFilesNew('foo', {exclude: ['*.ts']}); + * const b = findTextInFilesNew('foo', {exclude: ['*.js']}); + * ``` + * + * In this, `ab` will be the intersection of results from `a` and `b`. */ exclude?: GlobPattern[]; @@ -27,20 +50,21 @@ declare module 'vscode' { useExcludeSettings?: ExcludeSettingOptions; /** - * The maximum number of results to search for + * The maximum number of results to search for. Defaults to 20000 results. */ maxResults?: number; - /** - * Which file locations we should look for ignore (.gitignore or .ignore) files to respect. + * Which file locations have ignore (`.gitignore` or `.ignore`) files to follow. * - * When any of these fields are `undefined`, we will: - * - assume the value if possible (e.g. if only one is valid) - * or - * - follow settings using the value for the corresponding `search.use*IgnoreFiles` settting. + * When any of these fields are `undefined`, the value will either be assumed (e.g. if only one is valid), + * or it will follow settings based on the corresponding `search.use*IgnoreFiles` setting. * * Will log an error if an invalid combination is set. + * + * Although `.ignore` files are uncommon, they can be leveraged if there are patterns + * that should not be known to git, but should be known to the search providers. + * They should be in the same locations where `.gitignore` files are found, and they follow the same format. */ useIgnoreFiles?: { /** @@ -78,10 +102,10 @@ declare module 'vscode' { */ previewOptions?: { /** - * The maximum number of lines in the preview. + * The maximum number of lines in the preview of the match itself (not including surrounding context lines). * Only search providers that support multiline search will ever return more than one line in the match. */ - matchLines?: number; + numMatchLines?: number; /** * The maximum number of characters included per line. @@ -106,25 +130,22 @@ declare module 'vscode' { complete: Thenable; } - /* - * Options for following search.exclude and files.exclude settings. - */ + /** + * Options for following search.exclude and files.exclude settings. + */ export enum ExcludeSettingOptions { - /* + /** * Don't use any exclude settings. */ - none = 1, - /* - * Use: - * - files.exclude setting + None = 1, + /** + * Use the `files.exclude` setting */ - filesExclude = 2, - /* - * Use: - * - files.exclude setting - * - search.exclude setting + FilesExclude = 2, + /** + * Use the `files.exclude` and `search.exclude` settings */ - searchAndFilesExclude = 3 + SearchAndFilesExclude = 3 } export namespace workspace { @@ -133,7 +154,7 @@ declare module 'vscode' { * * Search text in files across all {@link workspace.workspaceFolders workspace folders} in the workspace. * @param query The query parameters for the search - the search string, whether it's case-sensitive, or a regex, or matches whole words. - * @param options An optional set of query options. Include and exclude patterns, maxResults, etc. + * @param options An optional set of query options. * @param callback A callback, called for each result * @param token A token that can be used to signal cancellation to the underlying search engine. * @return A thenable that resolves when the search is complete.