Skip to content

Commit e02a0d7

Browse files
committed
fix: improve rendering of highlighted differences in DiffViewerModal
1 parent c981609 commit e02a0d7

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

src/renderer/pages/backup/DiffViewerModal.tsx

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -76,25 +76,29 @@ const DiffViewerModal: React.FC<DiffViewerModalProps> = ({
7676
const renderContentWithHighlight = (
7777
content: string,
7878
compareContent: string
79-
): React.ReactElement[] => {
79+
): JSX.Element => {
8080
const lines = content.split("\n");
8181
const compareLines = compareContent.split("\n");
8282

83-
return lines.map((line, index) => {
84-
const isDifferent = compareLines[index] !== line;
85-
const style: React.CSSProperties = isDifferent
86-
? { backgroundColor: "#fff1f0", color: "#cf1322" }
87-
: {};
88-
89-
// Use line content + index for unique key, avoiding array index alone
90-
const uniqueKey = `${line.substring(0, 30)}-${index}`;
91-
92-
return (
93-
<div key={uniqueKey} style={style}>
94-
{line || " "}
95-
</div>
96-
);
97-
});
83+
return (
84+
<>
85+
{lines.map((line, index) => {
86+
const isDifferent = compareLines[index] !== line;
87+
const style: React.CSSProperties = isDifferent
88+
? { backgroundColor: "#fff1f0", color: "#cf1322" }
89+
: {};
90+
91+
// Use line content + index for unique key, avoiding array index alone
92+
const uniqueKey = `${line.substring(0, 30)}-${index}`;
93+
94+
return (
95+
<div key={uniqueKey} style={style}>
96+
{line || " "}
97+
</div>
98+
);
99+
})}
100+
</>
101+
);
98102
};
99103

100104
return (

0 commit comments

Comments
 (0)