Skip to content

Commit

Permalink
simpler edits collection, #43768
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Nov 18, 2019
1 parent 6536592 commit 6d541ca
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/vs/workbench/api/common/extHostFileSystemEventService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,14 @@ export class ExtHostFileSystemEventService implements ExtHostFileSystemEventServ
if (Object.isFrozen(bucket)) {
throw new TypeError('waitUntil cannot be called async');
}
const index = bucket.length;
const wrappedThenable = Promise.resolve(thenable).then(result => {
const promise = Promise.resolve(thenable).then(result => {
// ignore all results except for WorkspaceEdits. Those
// are stored in a spare array
if (result instanceof WorkspaceEdit) {
edits[index] = result;
edits.push(result);
}
});
bucket.push(wrappedThenable);
bucket.push(promise);
}
}
};
Expand All @@ -225,10 +224,8 @@ export class ExtHostFileSystemEventService implements ExtHostFileSystemEventServ
// and apply them in one go.
const allEdits = new Array<Array<IResourceFileEditDto | IResourceTextEditDto>>();
for (let edit of edits) {
if (edit) { // sparse array
let { edits } = typeConverter.WorkspaceEdit.from(edit, this._extHostDocumentsAndEditors);
allEdits.push(edits);
}
let { edits } = typeConverter.WorkspaceEdit.from(edit, this._extHostDocumentsAndEditors);
allEdits.push(edits);
}
return this._mainThreadTextEditors.$tryApplyWorkspaceEdit({ edits: flatten(allEdits) });
}
Expand Down

0 comments on commit 6d541ca

Please sign in to comment.