Ensure that a search with an immediately canceled token does not actually start a search. Fix possibly flaky findFiles test

This commit is contained in:
Rob Lourens
2018-09-05 10:33:48 -07:00
parent 0a45b590d4
commit b3ae3bd02c

View File

@@ -372,6 +372,10 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape {
}
}
if (token && token.isCancellationRequested) {
return TPromise.wrap([]);
}
const result = this._proxy.$startFileSearch(includePattern, includeFolder, excludePatternOrDisregardExcludes, maxResults, requestId);
if (token) {
token.onCancellationRequested(() => this._proxy.$cancelSearch(requestId));
@@ -428,10 +432,14 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape {
};
if (token) {
token.onCancellationRequested(() => {
isCanceled = true;
this._proxy.$cancelSearch(requestId);
});
if (token.isCancellationRequested) {
return TPromise.wrap(undefined);
} else {
token.onCancellationRequested(() => {
isCanceled = true;
this._proxy.$cancelSearch(requestId);
});
}
}
return this._proxy.$startTextSearch(query, queryOptions, requestId).then(