mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-30 21:41:46 +01:00
some 💄, some API todos
This commit is contained in:
@@ -17,7 +17,7 @@ vscode.workspace.registerFileSystemProvider(testFs.scheme, testFs, { isCaseSensi
|
||||
export async function createRandomFile(contents = '', dir: vscode.Uri | undefined = undefined, ext = ''): Promise<vscode.Uri> {
|
||||
let fakeFile: vscode.Uri;
|
||||
if (dir) {
|
||||
assert.equal(dir.scheme, testFs.scheme);
|
||||
assert.strictEqual(dir.scheme, testFs.scheme);
|
||||
fakeFile = dir.with({ path: dir.path + '/' + rndName() + ext });
|
||||
} else {
|
||||
fakeFile = vscode.Uri.parse(`${testFs.scheme}:/${rndName() + ext}`);
|
||||
@@ -117,3 +117,19 @@ export function assertNoRpcFromEntry(entry: [obj: any, name: string]) {
|
||||
assert.strictEqual(rpcPaths.length, 0, rpcPaths.join('\n'));
|
||||
assert.strictEqual(proxyPaths.length, 0, proxyPaths.join('\n')); // happens...
|
||||
}
|
||||
|
||||
export async function asPromise<T>(event: vscode.Event<T>, timeout = 1000): Promise<T> {
|
||||
return new Promise<T>((resolve, reject) => {
|
||||
|
||||
const handle = setTimeout(() => {
|
||||
sub.dispose();
|
||||
reject(new Error('asPromise TIMEOUT reached'));
|
||||
}, timeout);
|
||||
|
||||
const sub = event(e => {
|
||||
clearTimeout(handle);
|
||||
sub.dispose();
|
||||
resolve(e);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user