parent
ea1f61356f
commit
70ab0ada55
|
@ -520,6 +520,20 @@ suite('workspace-namespace', () => {
|
|||
});
|
||||
});
|
||||
|
||||
test('findFiles - null exclude', async () => {
|
||||
await vscode.workspace.findFiles('**/file.txt').then((res) => {
|
||||
// search.exclude folder is still searched, files.exclude folder is not
|
||||
assert.equal(res.length, 1);
|
||||
assert.equal(basename(vscode.workspace.asRelativePath(res[0])), 'file.txt');
|
||||
});
|
||||
|
||||
await vscode.workspace.findFiles('**/file.txt', null).then((res) => {
|
||||
// search.exclude and files.exclude folders are both searched
|
||||
assert.equal(res.length, 2);
|
||||
assert.equal(basename(vscode.workspace.asRelativePath(res[0])), 'file.txt');
|
||||
});
|
||||
});
|
||||
|
||||
test('findFiles - exclude', () => {
|
||||
return vscode.workspace.findFiles('**/*.png').then((res) => {
|
||||
assert.equal(res.length, 2);
|
||||
|
|
8
extensions/vscode-api-tests/testWorkspace/.vscode/settings.json
vendored
Normal file
8
extensions/vscode-api-tests/testWorkspace/.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"search.exclude": {
|
||||
"**/search-exclude/**": true
|
||||
},
|
||||
"files.exclude": {
|
||||
"**/files-exclude/**": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
file
|
|
@ -0,0 +1 @@
|
|||
file
|
|
@ -988,8 +988,9 @@ export namespace GlobPattern {
|
|||
|
||||
export function from(pattern: vscode.GlobPattern): string | types.RelativePattern;
|
||||
export function from(pattern: undefined): undefined;
|
||||
export function from(pattern: vscode.GlobPattern | undefined): string | types.RelativePattern | undefined;
|
||||
export function from(pattern: vscode.GlobPattern | undefined): string | types.RelativePattern | undefined {
|
||||
export function from(pattern: null): null;
|
||||
export function from(pattern: vscode.GlobPattern | undefined | null): string | types.RelativePattern | undefined | null;
|
||||
export function from(pattern: vscode.GlobPattern | undefined | null): string | types.RelativePattern | undefined | null {
|
||||
if (pattern instanceof types.RelativePattern) {
|
||||
return pattern;
|
||||
}
|
||||
|
|
|
@ -408,7 +408,10 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape, IExtHostWorkspac
|
|||
|
||||
// --- search ---
|
||||
|
||||
findFiles(include: string | RelativePattern | undefined, exclude: vscode.GlobPattern | undefined, maxResults: number | undefined, extensionId: ExtensionIdentifier, token: vscode.CancellationToken = CancellationToken.None): Promise<vscode.Uri[]> {
|
||||
/**
|
||||
* Note, null/undefined have different and important meanings for "exclude"
|
||||
*/
|
||||
findFiles(include: string | RelativePattern | undefined, exclude: vscode.GlobPattern | null | undefined, maxResults: number | undefined, extensionId: ExtensionIdentifier, token: vscode.CancellationToken = CancellationToken.None): Promise<vscode.Uri[]> {
|
||||
this._logService.trace(`extHostWorkspace#findFiles: fileSearch, extension: ${extensionId.value}, entryPoint: findFiles`);
|
||||
|
||||
let includePattern: string | undefined;
|
||||
|
|
|
@ -63,7 +63,6 @@ import * as vscode from 'vscode';
|
|||
import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { originalFSPath } from 'vs/base/common/resources';
|
||||
import { CLIServer } from 'vs/workbench/api/node/extHostCLIServer';
|
||||
import { withNullAsUndefined } from 'vs/base/common/types';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { IURITransformer } from 'vs/base/common/uriIpc';
|
||||
|
@ -602,7 +601,8 @@ export function createApiFactory(
|
|||
return extHostWorkspace.getRelativePath(pathOrUri, includeWorkspace);
|
||||
},
|
||||
findFiles: (include, exclude, maxResults?, token?) => {
|
||||
return extHostWorkspace.findFiles(typeConverters.GlobPattern.from(include), typeConverters.GlobPattern.from(withNullAsUndefined(exclude)), maxResults, extension.identifier, token);
|
||||
// Note, undefined/null have different meanings on "exclude"
|
||||
return extHostWorkspace.findFiles(typeConverters.GlobPattern.from(include), typeConverters.GlobPattern.from(exclude), maxResults, extension.identifier, token);
|
||||
},
|
||||
findTextInFiles: (query: vscode.TextSearchQuery, optionsOrCallback: vscode.FindTextInFilesOptions | ((result: vscode.TextSearchResult) => void), callbackOrToken?: vscode.CancellationToken | ((result: vscode.TextSearchResult) => void), token?: vscode.CancellationToken) => {
|
||||
let options: vscode.FindTextInFilesOptions;
|
||||
|
|
Loading…
Reference in a new issue