From c0a5a09ab4dfb95168709557b9b9b71779bc70d0 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Mon, 29 Jan 2018 12:57:40 +0100 Subject: [PATCH] fix #33528 --- src/vs/vscode.d.ts | 5 +++-- .../api/electron-browser/mainThreadWorkspace.ts | 7 ++++--- src/vs/workbench/api/node/extHost.protocol.ts | 2 +- src/vs/workbench/api/node/extHostTypeConverters.ts | 6 +++--- src/vs/workbench/api/node/extHostWorkspace.ts | 12 +++++++----- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index c488cd29b57..8c6a5442b8e 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 b1cd93ae038..721a2df3e40 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 e289cf18c82..cd5e404db14 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 38ce5b91889..366a64d45f4 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 5ead32afa25..ec70503062e 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)); } -- GitLab