提交 11c8300b 编写于 作者: R Rob Lourens

Ensure search cancel takes effect immediately, and still works when search failed

上级 41c47d1b
...@@ -129,7 +129,14 @@ export class SearchService extends Disposable implements ISearchService { ...@@ -129,7 +129,14 @@ export class SearchService extends Disposable implements ISearchService {
const providerPromise = TPromise.join(providerActivations) const providerPromise = TPromise.join(providerActivations)
.then(() => this.extensionService.whenInstalledExtensionsRegistered()) .then(() => this.extensionService.whenInstalledExtensionsRegistered())
.then(() => this.searchWithProviders(query, onProviderProgress, token)) .then(() => {
// Cancel faster if search was canceled while waiting for extensions
if (token && token.isCancellationRequested) {
return TPromise.wrapError(canceled());
}
return this.searchWithProviders(query, onProviderProgress, token);
})
.then(completes => { .then(completes => {
completes = completes.filter(c => !!c); completes = completes.filter(c => !!c);
if (!completes.length) { if (!completes.length) {
...@@ -150,7 +157,7 @@ export class SearchService extends Disposable implements ISearchService { ...@@ -150,7 +157,7 @@ export class SearchService extends Disposable implements ISearchService {
return TPromise.wrapError(errs[0]); return TPromise.wrapError(errs[0]);
}); });
return providerPromise.then(value => { const searchP = providerPromise.then(value => {
const values = [value]; const values = [value];
const result: ISearchComplete = { const result: ISearchComplete = {
...@@ -179,6 +186,15 @@ export class SearchService extends Disposable implements ISearchService { ...@@ -179,6 +186,15 @@ export class SearchService extends Disposable implements ISearchService {
return result; return result;
}); });
return new TPromise((resolve, reject) => {
if (token) {
token.onCancellationRequested(() => {
reject(canceled());
});
}
searchP.then(resolve, reject);
});
} }
private getSchemesInQuery(query: ISearchQuery): Set<string> { private getSchemesInQuery(query: ISearchQuery): Set<string> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册