Skip to content

Commit

Permalink
bugfix: Blame decorations being recycled across files (#491)
Browse files Browse the repository at this point in the history
`merge` is mutable, and was mutating the previous decoration record for
a file
  • Loading branch information
metacurb authored Apr 2, 2024
1 parent 5aa65c1 commit 763fd57
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/blamer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class Blamer {
const existingRecord = await this.getRecordForFile(fileName);
return await this.storage.set<DecorationRecord>(
fileName,
mapToDecorationRecord(merge(existingRecord, update)),
merge({}, existingRecord, update),
);
}

Expand Down Expand Up @@ -214,6 +214,9 @@ export class Blamer {
}

if (existingRecord) {
this.logger.debug("Blame already exists for file, re-applying decorations", {
fileName,
});
this.decorationManager.reApplyDecorations(textEditor, existingRecord);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/mapping/map-to-decoration-record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ const defaultRecord: DecorationRecord = {
};

export const mapToDecorationRecord = (record: Partial<DecorationRecord>): DecorationRecord =>
merge(defaultRecord, record);
merge({}, defaultRecord, record);

0 comments on commit 763fd57

Please sign in to comment.