mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 02:58:56 +01:00
watcher - correlate events to their requesting source (#194776)
* watcher - emit `URI` instead of `string` for faster `fsPath` compute (for #194341) * wip * more * adopt * some cleanup * cleanup * cleanup * cleanup * cleanup * cleanup * cleanup * implement correlation * cleanup * add correlation * undo, leave for later * tests * tests * tests * tests * tests * log cId * simpler correlation id * 💄 * tests * runs * skip normalization * fix tests * tests * fix tests * add `createWatcher` API * partition events in ext host * allow custom excludes * remove disk file change * 💄 * 💄 * 💄 * wire in * wire in
This commit is contained in:
@@ -27,19 +27,28 @@ suite('vscode API - workspace-watcher', () => {
|
||||
}
|
||||
}
|
||||
|
||||
teardown(assertNoRpc);
|
||||
let fs: WatcherTestFs;
|
||||
let disposable: vscode.Disposable;
|
||||
|
||||
test('createFileSystemWatcher', async function () {
|
||||
const fs = new WatcherTestFs('watcherTest', false);
|
||||
vscode.workspace.registerFileSystemProvider('watcherTest', fs);
|
||||
function onDidWatchPromise() {
|
||||
const onDidWatchPromise = new Promise<IWatchRequest>(resolve => {
|
||||
fs.onDidWatch(request => resolve(request));
|
||||
});
|
||||
|
||||
function onDidWatchPromise() {
|
||||
const onDidWatchPromise = new Promise<IWatchRequest>(resolve => {
|
||||
fs.onDidWatch(request => resolve(request));
|
||||
});
|
||||
return onDidWatchPromise;
|
||||
}
|
||||
|
||||
return onDidWatchPromise;
|
||||
}
|
||||
setup(() => {
|
||||
fs = new WatcherTestFs('watcherTest', false);
|
||||
disposable = vscode.workspace.registerFileSystemProvider('watcherTest', fs);
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
disposable.dispose();
|
||||
assertNoRpc();
|
||||
});
|
||||
|
||||
test('createFileSystemWatcher (old style)', async function () {
|
||||
|
||||
// Non-recursive
|
||||
let watchUri = vscode.Uri.from({ scheme: 'watcherTest', path: '/somePath/folder' });
|
||||
@@ -59,4 +68,29 @@ suite('vscode API - workspace-watcher', () => {
|
||||
assert.strictEqual(request.uri.toString(), watchUri.toString());
|
||||
assert.strictEqual(request.options.recursive, true);
|
||||
});
|
||||
|
||||
test('createFileSystemWatcher (new style)', async function () {
|
||||
|
||||
// Non-recursive
|
||||
let watchUri = vscode.Uri.from({ scheme: 'watcherTest', path: '/somePath/folder' });
|
||||
const watcher = vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(watchUri, '*.txt'), { excludes: ['testing'], ignoreChangeEvents: true });
|
||||
let request = await onDidWatchPromise();
|
||||
|
||||
assert.strictEqual(request.uri.toString(), watchUri.toString());
|
||||
assert.strictEqual(request.options.recursive, false);
|
||||
assert.strictEqual(request.options.excludes.length, 1);
|
||||
assert.strictEqual(request.options.excludes[0], 'testing');
|
||||
|
||||
watcher.dispose();
|
||||
|
||||
// Recursive
|
||||
watchUri = vscode.Uri.from({ scheme: 'watcherTest', path: '/somePath/folder' });
|
||||
vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(watchUri, '**/*.txt'), { excludes: ['testing'], ignoreCreateEvents: true });
|
||||
request = await onDidWatchPromise();
|
||||
|
||||
assert.strictEqual(request.uri.toString(), watchUri.toString());
|
||||
assert.strictEqual(request.options.recursive, true);
|
||||
assert.strictEqual(request.options.excludes.length, 1);
|
||||
assert.strictEqual(request.options.excludes[0], 'testing');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user