mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 10:38:59 +01:00
introduce findFiles2 API (#203844)
* introduce first version of FindFiles2 API
This commit is contained in:
@@ -597,6 +597,45 @@ suite('vscode API - workspace', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('`findFiles2`', () => {
|
||||
return vscode.workspace.findFiles2('*image.png').then((res) => {
|
||||
assert.strictEqual(res.length, 4);
|
||||
// TODO: see why this is fuzzy matching
|
||||
});
|
||||
});
|
||||
|
||||
test('findFiles2 - null exclude', async () => {
|
||||
await vscode.workspace.findFiles2('**/file.txt', { useDefaultExcludes: true, useDefaultSearchExcludes: false }).then((res) => {
|
||||
// file.exclude folder is still searched, search.exclude folder is not
|
||||
assert.strictEqual(res.length, 1);
|
||||
assert.strictEqual(basename(vscode.workspace.asRelativePath(res[0])), 'file.txt');
|
||||
});
|
||||
|
||||
await vscode.workspace.findFiles2('**/file.txt', { useDefaultExcludes: false, useDefaultSearchExcludes: false }).then((res) => {
|
||||
// search.exclude and files.exclude folders are both searched
|
||||
assert.strictEqual(res.length, 2);
|
||||
assert.strictEqual(basename(vscode.workspace.asRelativePath(res[0])), 'file.txt');
|
||||
});
|
||||
});
|
||||
|
||||
test('findFiles2, exclude', () => {
|
||||
return vscode.workspace.findFiles2('*image.png', { exclude: '**/sub/**' }).then((res) => {
|
||||
assert.strictEqual(res.length, 3);
|
||||
// TODO: see why this is fuzzy matching
|
||||
});
|
||||
});
|
||||
|
||||
test('findFiles2, cancellation', () => {
|
||||
|
||||
const source = new vscode.CancellationTokenSource();
|
||||
const token = source.token; // just to get an instance first
|
||||
source.cancel();
|
||||
|
||||
return vscode.workspace.findFiles2('*.js', {}, token).then((res) => {
|
||||
assert.deepStrictEqual(res, []);
|
||||
});
|
||||
});
|
||||
|
||||
test('findTextInFiles', async () => {
|
||||
const options: vscode.FindTextInFilesOptions = {
|
||||
include: '*.ts',
|
||||
|
||||
Reference in New Issue
Block a user