api - allow to provide a cancellation token to findFiles. Fixes #1553

This commit is contained in:
Johannes Rieken
2015-12-22 09:29:35 +01:00
parent 28e35df8b9
commit 4dfa345e91
4 changed files with 56 additions and 14 deletions

View File

@@ -6,7 +6,7 @@
'use strict';
import * as assert from 'assert';
import {workspace, TextDocument, window, Position, Uri} from 'vscode';
import {workspace, TextDocument, window, Position, Uri, CancellationTokenSource} from 'vscode';
import {createRandomFile, deleteFile, cleanUp, pathEquals} from './utils';
import {join, basename} from 'path';
import * as fs from 'fs';
@@ -125,4 +125,15 @@ suite('workspace-namespace', () => {
assert.equal(basename(workspace.asRelativePath(res[0])), 'far.js');
});
});
test('findFiles, cancellation', () => {
const source = new CancellationTokenSource();
const token = source.token; // just to get an instance first
source.cancel();
return workspace.findFiles('*.js', null, 100, token).then((res) => {
assert.equal(res, void 0);
});
});
});