Check if there is an edit before applying it to the buffer (#170301)

This was throwing an error before if you were writing `undefined` to a property that didn't exist.

Fixes #168092
This commit is contained in:
Tyler James Leonhardt 2022-12-30 14:44:42 -05:00 committed by GitHub
parent 653ee6ddf0
commit 741531e106
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -51,7 +51,7 @@ export class JSONEditingService implements IJSONEditingService {
let hasEdits: boolean = false;
for (const value of values) {
const edit = this.getEdits(model, value)[0];
hasEdits = this.applyEditsToBuffer(edit, model);
hasEdits = !!edit && this.applyEditsToBuffer(edit, model);
}
if (hasEdits) {
return this.textFileService.save(model.uri);