Skip to content

Commit

Permalink
Fix duplicate hunks when using updated hunks list
Browse files Browse the repository at this point in the history
  • Loading branch information
blakef committed Feb 26, 2024
1 parent b6bbf79 commit 63eacfc
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/components/common/Diff/Diff.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down Expand Up @@ -323,21 +326,21 @@ const Diff = ({
selectedChanges={selectedChanges}
>
{(hunks: HunkData[]) =>
hunks.map((hunk) => (
<Fragment key={hunk.content}>
{updatedHunks.map((hunk) => [
hunks
.map((_, i) => updatedHunks[i])
.map((hunk) => (
<Fragment key={hunk.content}>
<Decoration key={'decoration-' + hunk.content}>
<More>{hunk.content}</More>
</Decoration>,
</Decoration>
<Hunk
key={hunk.content}
hunk={hunk}
// @ts-ignore-next-line
gutterEvents={{ onClick: onToggleChangeSelection }}
/>,
])}
</Fragment>
))
/>
</Fragment>
))
}
</DiffView>
)}
Expand Down

0 comments on commit 63eacfc

Please sign in to comment.