提交 c0a5a09a 编写于 作者: J Johannes Rieken

fix #33528

上级 b338f57e
...@@ -5495,13 +5495,14 @@ declare module 'vscode' { ...@@ -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) * 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). * 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 * @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 maxResults An upper-bound for the result.
* @param token A token that can be used to signal cancellation to the underlying search engine. * @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 * @return A thenable that resolves to an array of resource identifiers. Will return no results if no
* [workspace folders](#workspace.workspaceFolders) are opened. * [workspace folders](#workspace.workspaceFolders) are opened.
*/ */
export function findFiles(include: GlobPattern, exclude?: GlobPattern, maxResults?: number, token?: CancellationToken): Thenable<Uri[]>; export function findFiles(include: GlobPattern, exclude?: GlobPattern | null, maxResults?: number, token?: CancellationToken): Thenable<Uri[]>;
/** /**
* Save all dirty files. * Save all dirty files.
......
...@@ -97,7 +97,7 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape { ...@@ -97,7 +97,7 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
// --- search --- // --- search ---
$startSearch(includePattern: string, includeFolder: string, excludePattern: string, maxResults: number, requestId: number): Thenable<URI[]> { $startSearch(includePattern: string, includeFolder: string, excludePatternOrDisregardExcludes: string | false, maxResults: number, requestId: number): Thenable<URI[]> {
const workspace = this._contextService.getWorkspace(); const workspace = this._contextService.getWorkspace();
if (!workspace.folders.length) { if (!workspace.folders.length) {
return undefined; return undefined;
...@@ -129,7 +129,8 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape { ...@@ -129,7 +129,8 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
type: QueryType.File, type: QueryType.File,
maxResults, maxResults,
includePattern: { [typeof includePattern === 'string' ? includePattern : undefined]: true }, 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, useRipgrep,
ignoreSymlinks ignoreSymlinks
}; };
...@@ -168,4 +169,4 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape { ...@@ -168,4 +169,4 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
return result.results.every(each => each.success === true); return result.results.every(each => each.success === true);
}); });
} }
} }
\ No newline at end of file
...@@ -346,7 +346,7 @@ export interface MainThreadTelemetryShape extends IDisposable { ...@@ -346,7 +346,7 @@ export interface MainThreadTelemetryShape extends IDisposable {
} }
export interface MainThreadWorkspaceShape extends IDisposable { export interface MainThreadWorkspaceShape extends IDisposable {
$startSearch(includePattern: string, includeFolder: string, excludePattern: string, maxResults: number, requestId: number): Thenable<UriComponents[]>; $startSearch(includePattern: string, includeFolder: string, excludePatternOrDisregardExcludes: string | false, maxResults: number, requestId: number): Thenable<UriComponents[]>;
$cancelSearch(requestId: number): Thenable<boolean>; $cancelSearch(requestId: number): Thenable<boolean>;
$saveAll(includeUntitled?: boolean): Thenable<boolean>; $saveAll(includeUntitled?: boolean): Thenable<boolean>;
$updateWorkspaceFolders(extensionName: string, index: number, deleteCount: number, workspaceFoldersToAdd: { uri: UriComponents, name?: string }[]): Thenable<void>; $updateWorkspaceFolders(extensionName: string, index: number, deleteCount: number, workspaceFoldersToAdd: { uri: UriComponents, name?: string }[]): Thenable<void>;
......
...@@ -603,11 +603,11 @@ export function toGlobPattern(pattern: vscode.GlobPattern): string | IRelativePa ...@@ -603,11 +603,11 @@ export function toGlobPattern(pattern: vscode.GlobPattern): string | IRelativePa
return pattern; return pattern;
} }
if (!isRelativePattern(pattern)) { if (isRelativePattern(pattern)) {
return undefined; 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 { function isRelativePattern(obj: any): obj is vscode.RelativePattern {
......
...@@ -331,16 +331,18 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape { ...@@ -331,16 +331,18 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape {
} }
} }
let excludePattern: string; let excludePatternOrDisregardExcludes: string | false;
if (exclude) { if (exclude === null) {
excludePatternOrDisregardExcludes = false;
} else if (exclude) {
if (typeof exclude === 'string') { if (typeof exclude === 'string') {
excludePattern = exclude; excludePatternOrDisregardExcludes = exclude;
} else { } 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) { if (token) {
token.onCancellationRequested(() => this._proxy.$cancelSearch(requestId)); token.onCancellationRequested(() => this._proxy.$cancelSearch(requestId));
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册