Skip to content

Commit 5620d5b

Browse files
committed
Fix showDiff args: use pre-patch buffer for consistent indices
1 parent 24be7cd commit 5620d5b

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/patches/sessionColor.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,15 @@ export const writeSessionColor = (oldFile: string): string | null => {
4242
const match = result.match(pattern);
4343
if (!match || match.index === undefined) continue;
4444

45+
const prePatch = result;
4546
const replacement = INJECTION + match[0];
4647
result =
47-
result.slice(0, match.index) +
48+
prePatch.slice(0, match.index) +
4849
replacement +
49-
result.slice(match.index + match[0].length);
50+
prePatch.slice(match.index + match[0].length);
5051

5152
showDiff(
52-
oldFile,
53+
prePatch,
5354
result,
5455
replacement,
5556
match.index,

0 commit comments

Comments
 (0)