Skip to content

Commit

Permalink
Merge pull request #378 from blakef/fix-duplicate-hunks
Browse files Browse the repository at this point in the history
Fix duplicate hunks when using updated hunks list
  • Loading branch information
lunaleaps authored Feb 26, 2024
2 parents b6bbf79 + 63eacfc commit 3ebded0
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 3ebded0

Please sign in to comment.