Fix unhandled cancel warnings from text search
This commit is contained in:
parent
670d8bb7c5
commit
57f13b7f26
1 changed files with 10 additions and 3 deletions
|
@ -67,13 +67,20 @@ export class SearchService implements IRawSearchService {
|
|||
}
|
||||
|
||||
public textSearch(config: IRawSearch): Event<ISerializedSearchProgressItem | ISerializedSearchComplete> {
|
||||
let promise: CancelablePromise<void>;
|
||||
let promise: CancelablePromise<ISerializedSearchComplete>;
|
||||
|
||||
const emitter = new Emitter<ISerializedSearchProgressItem | ISerializedSearchComplete>({
|
||||
onFirstListenerDidAdd: () => {
|
||||
promise = createCancelablePromise(token => {
|
||||
return (config.useRipgrep ? this.ripgrepTextSearch(config, p => emitter.fire(p), token) : this.legacyTextSearch(config, p => emitter.fire(p), token))
|
||||
.then(c => emitter.fire(c), err => emitter.fire({ type: 'error', error: { message: err.message, stack: err.stack } }));
|
||||
return (config.useRipgrep ? this.ripgrepTextSearch(config, p => emitter.fire(p), token) : this.legacyTextSearch(config, p => emitter.fire(p), token));
|
||||
});
|
||||
|
||||
promise.then(
|
||||
c => emitter.fire(c),
|
||||
err => {
|
||||
if (!isPromiseCanceledError(err)) {
|
||||
emitter.fire({ type: 'error', error: { message: err.message, stack: err.stack } });
|
||||
}
|
||||
});
|
||||
},
|
||||
onLastListenerRemove: () => {
|
||||
|
|
Loading…
Reference in a new issue