diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index c488cd29b57637480bc211a78845e6849b23cebe..8c6a5442b8ea527bd14b46276885bda2571cd2be 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -5495,13 +5495,14 @@ declare module 'vscode' { * will be matched against the file paths of resulting matches relative to their workspace. Use a [relative pattern](#RelativePattern) * to restrict the search results to a [workspace folder](#WorkspaceFolder). * @param exclude A [glob pattern](#GlobPattern) that defines files and folders to exclude. The glob pattern - * will be matched against the file paths of resulting matches relative to their workspace. + * will be matched against the file paths of resulting matches relative to their workspace. When `undefined` only default excludes will + * apply, when `null` no excludes will apply. * @param maxResults An upper-bound for the result. * @param token A token that can be used to signal cancellation to the underlying search engine. * @return A thenable that resolves to an array of resource identifiers. Will return no results if no * [workspace folders](#workspace.workspaceFolders) are opened. */ - export function findFiles(include: GlobPattern, exclude?: GlobPattern, maxResults?: number, token?: CancellationToken): Thenable; + export function findFiles(include: GlobPattern, exclude?: GlobPattern | null, maxResults?: number, token?: CancellationToken): Thenable; /** * Save all dirty files. diff --git a/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts b/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts index b1cd93ae038a84395f04e0d3e5644cf07b76a986..721a2df3e409a12e23853ab6a4acdb9a5128779a 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts @@ -97,7 +97,7 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape { // --- search --- - $startSearch(includePattern: string, includeFolder: string, excludePattern: string, maxResults: number, requestId: number): Thenable { + $startSearch(includePattern: string, includeFolder: string, excludePatternOrDisregardExcludes: string | false, maxResults: number, requestId: number): Thenable { const workspace = this._contextService.getWorkspace(); if (!workspace.folders.length) { return undefined; @@ -129,7 +129,8 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape { type: QueryType.File, maxResults, includePattern: { [typeof includePattern === 'string' ? includePattern : undefined]: true }, - excludePattern: { [typeof excludePattern === 'string' ? excludePattern : undefined]: true }, + excludePattern: { [typeof excludePatternOrDisregardExcludes === 'string' ? excludePatternOrDisregardExcludes : undefined]: true }, + disregardExcludeSettings: excludePatternOrDisregardExcludes === false, useRipgrep, ignoreSymlinks }; @@ -168,4 +169,4 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape { return result.results.every(each => each.success === true); }); } -} \ No newline at end of file +} diff --git a/src/vs/workbench/api/node/extHost.protocol.ts b/src/vs/workbench/api/node/extHost.protocol.ts index e289cf18c822fffc6996e16b9fd75e2be8901ffa..cd5e404db146593dc64b5047aad6214e9a50d84e 100644 --- a/src/vs/workbench/api/node/extHost.protocol.ts +++ b/src/vs/workbench/api/node/extHost.protocol.ts @@ -346,7 +346,7 @@ export interface MainThreadTelemetryShape extends IDisposable { } export interface MainThreadWorkspaceShape extends IDisposable { - $startSearch(includePattern: string, includeFolder: string, excludePattern: string, maxResults: number, requestId: number): Thenable; + $startSearch(includePattern: string, includeFolder: string, excludePatternOrDisregardExcludes: string | false, maxResults: number, requestId: number): Thenable; $cancelSearch(requestId: number): Thenable; $saveAll(includeUntitled?: boolean): Thenable; $updateWorkspaceFolders(extensionName: string, index: number, deleteCount: number, workspaceFoldersToAdd: { uri: UriComponents, name?: string }[]): Thenable; diff --git a/src/vs/workbench/api/node/extHostTypeConverters.ts b/src/vs/workbench/api/node/extHostTypeConverters.ts index 38ce5b918897175d83a76e0b145f0eda497cf549..366a64d45f480dccc24489b56d17f2247cf3cd4c 100644 --- a/src/vs/workbench/api/node/extHostTypeConverters.ts +++ b/src/vs/workbench/api/node/extHostTypeConverters.ts @@ -603,11 +603,11 @@ export function toGlobPattern(pattern: vscode.GlobPattern): string | IRelativePa return pattern; } - if (!isRelativePattern(pattern)) { - return undefined; + if (isRelativePattern(pattern)) { + return new types.RelativePattern(pattern.base, pattern.pattern); } - return new types.RelativePattern(pattern.base, pattern.pattern); + return pattern; // preserve `undefined` and `null` } function isRelativePattern(obj: any): obj is vscode.RelativePattern { diff --git a/src/vs/workbench/api/node/extHostWorkspace.ts b/src/vs/workbench/api/node/extHostWorkspace.ts index 5ead32afa25fa33a5b37aa8097163b04465b9dcc..ec70503062e4383796499dc002499392177b42da 100644 --- a/src/vs/workbench/api/node/extHostWorkspace.ts +++ b/src/vs/workbench/api/node/extHostWorkspace.ts @@ -331,16 +331,18 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape { } } - let excludePattern: string; - if (exclude) { + let excludePatternOrDisregardExcludes: string | false; + if (exclude === null) { + excludePatternOrDisregardExcludes = false; + } else if (exclude) { if (typeof exclude === 'string') { - excludePattern = exclude; + excludePatternOrDisregardExcludes = exclude; } else { - excludePattern = exclude.pattern; + excludePatternOrDisregardExcludes = exclude.pattern; } } - const result = this._proxy.$startSearch(includePattern, includeFolder, excludePattern, maxResults, requestId); + const result = this._proxy.$startSearch(includePattern, includeFolder, excludePatternOrDisregardExcludes, maxResults, requestId); if (token) { token.onCancellationRequested(() => this._proxy.$cancelSearch(requestId)); }