Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix search cancellation #54840

Merged
merged 1 commit into from
Jul 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/vs/base/parts/ipc/common/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ export class ChannelClient implements IChannelClient, IDisposable {
let uninitializedPromise: TPromise<any> | null = null;
const emitter = new Emitter<any>({
onFirstListenerAdd: () => {
uninitializedPromise = this.whenInitialized().then(() => {
uninitializedPromise = this.whenInitialized();
uninitializedPromise.then(() => {
uninitializedPromise = null;
this.send(request.raw);
});
Expand Down
1 change: 1 addition & 0 deletions src/vs/base/parts/ipc/node/ipc.cp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export class Client implements IChannelClient, IDisposable {
}

this.activeRequests.splice(this.activeRequests.indexOf(listener), 1);
listener.dispose();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh man, great catch.


if (this.activeRequests.length === 0) {
this.disposeDelayer.trigger(() => this.disposeClient());
Expand Down
5 changes: 3 additions & 2 deletions src/vs/workbench/services/search/node/searchService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,10 @@ export class DiskSearch implements ISearchResultProvider {
}

public static collectResultsFromEvent(event: Event<ISerializedSearchProgressItem | ISerializedSearchComplete>): PPromise<ISearchComplete, ISearchProgressItem> {
let listener: IDisposable;
const promise = new PPromise<ISerializedSearchSuccess, ISerializedSearchProgressItem>((c, e, p) => {
setTimeout(() => {
const listener = event(ev => {
listener = event(ev => {
if (isSerializedSearchComplete(ev)) {
if (isSerializedSearchSuccess(ev)) {
c(ev);
Expand All @@ -391,7 +392,7 @@ export class DiskSearch implements ISearchResultProvider {
}
});
}, 0);
});
}, () => listener.dispose());

return DiskSearch.collectResults(promise);
}
Expand Down