From 63eacfcfb86b28ad66d0c6a504fc03e96c5cee78 Mon Sep 17 00:00:00 2001 From: Blake Friedman Date: Mon, 26 Feb 2024 15:47:20 +0000 Subject: [PATCH] Fix duplicate hunks when using updated hunks list --- src/components/common/Diff/Diff.tsx | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/components/common/Diff/Diff.tsx b/src/components/common/Diff/Diff.tsx index 018af59e..a0fb43d6 100644 --- a/src/components/common/Diff/Diff.tsx +++ b/src/components/common/Diff/Diff.tsx @@ -272,7 +272,10 @@ const Diff = ({ toVersion, }) - const updatedHunks = React.useMemo(() => getHunksWithAppName(hunks), [hunks]) + const updatedHunks: HunkData[] = React.useMemo( + () => getHunksWithAppName(hunks), + [hunks] + ) const tokens: HunkTokens = React.useMemo( () => tokenize(hunks, { @@ -323,21 +326,21 @@ const Diff = ({ selectedChanges={selectedChanges} > {(hunks: HunkData[]) => - hunks.map((hunk) => ( - - {updatedHunks.map((hunk) => [ + hunks + .map((_, i) => updatedHunks[i]) + .map((hunk) => ( + {hunk.content} - , + , - ])} - - )) + /> + + )) } )}