Skip to content

Commit a777769

Browse files
committed
ui(diff): VSCode-style highlighting in [DiffView](webview-ui/src/components/common/DiffView.tsx)\n\n- Tint only content and +/- gutter; keep line-number columns neutral\n- Match look of VSCode unified diff blocks (clear red/green bands)\n
1 parent f35aeed commit a777769

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

webview-ui/src/components/common/DiffView.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,15 @@ const DiffView = memo(({ source }: DiffViewProps) => {
9292
}}>
9393
<tbody>
9494
{diffLines.map((line, idx) => {
95-
const bgColor =
95+
// Backgrounds: tint only the content and +/- gutter, not the line-number columns
96+
const contentBg =
9697
line.type === "addition"
9798
? "var(--vscode-diffEditor-insertedTextBackground)"
9899
: line.type === "deletion"
99100
? "var(--vscode-diffEditor-removedTextBackground)"
100101
: "transparent"
102+
// Use same tint for the +/- gutter for a cohesive band effect
103+
const gutterBg = contentBg
101104

102105
const lineColor =
103106
line.type === "addition"
@@ -107,7 +110,7 @@ const DiffView = memo(({ source }: DiffViewProps) => {
107110
: "var(--vscode-editorLineNumber-foreground)"
108111

109112
return (
110-
<tr key={idx} style={{ backgroundColor: bgColor }}>
113+
<tr key={idx}>
111114
{/* Old line number */}
112115
<td
113116
style={{
@@ -142,6 +145,7 @@ const DiffView = memo(({ source }: DiffViewProps) => {
142145
style={{
143146
width: "20px",
144147
textAlign: "center",
148+
backgroundColor: gutterBg,
145149
color:
146150
line.type === "addition"
147151
? "var(--vscode-gitDecoration-addedResourceForeground)"
@@ -165,6 +169,7 @@ const DiffView = memo(({ source }: DiffViewProps) => {
165169
fontFamily: "var(--vscode-editor-font-family)",
166170
color: "var(--vscode-editor-foreground)",
167171
width: "100%",
172+
backgroundColor: contentBg,
168173
}}>
169174
{line.content}
170175
</td>

0 commit comments

Comments
 (0)