From fa11186b88b80d68ea65f4407ab6492a27887318 Mon Sep 17 00:00:00 2001 From: BeauAgst <10343831+BeauAgst@users.noreply.github.com> Date: Tue, 2 Apr 2024 11:21:11 +0100 Subject: [PATCH] bugfix: Blame decorations being recycled across files --- src/blamer.ts | 5 ++++- src/mapping/map-to-decoration-record.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/blamer.ts b/src/blamer.ts index e3a9b39..2eaf44c 100644 --- a/src/blamer.ts +++ b/src/blamer.ts @@ -64,7 +64,7 @@ export class Blamer { const existingRecord = await this.getRecordForFile(fileName); return await this.storage.set( fileName, - mapToDecorationRecord(merge(existingRecord, update)), + merge({}, existingRecord, update), ); } @@ -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; } diff --git a/src/mapping/map-to-decoration-record.ts b/src/mapping/map-to-decoration-record.ts index 50c4935..6d2e84a 100644 --- a/src/mapping/map-to-decoration-record.ts +++ b/src/mapping/map-to-decoration-record.ts @@ -10,4 +10,4 @@ const defaultRecord: DecorationRecord = { }; export const mapToDecorationRecord = (record: Partial): DecorationRecord => - merge(defaultRecord, record); + merge({}, defaultRecord, record);