From 4db1cd9fcd013af2a2e3ceaa54ad7dd33eba568b Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 30 Jul 2025 13:36:20 -0700 Subject: [PATCH] update diff colors --- src/ui/ColoredDiff.tsx | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/ui/ColoredDiff.tsx b/src/ui/ColoredDiff.tsx index 991d2576f..803225f71 100644 --- a/src/ui/ColoredDiff.tsx +++ b/src/ui/ColoredDiff.tsx @@ -2,6 +2,15 @@ import { diffWordsWithSpace } from "diff"; import { Box, Text } from "ink"; import React from "react"; +// Color constants for diff display +const COLORS = { + ADDITION_BG: "#325b30", + DELETION_BG: "#712f37", + ADDITION_HIGHLIGHT: "#59a467", + DELETION_HIGHLIGHT: "#a75e6d", + LINE_NUMBER: "gray", +} as const; + interface DiffLine { type: "add" | "del" | "context" | "hunk" | "other"; oldLine?: number; @@ -81,7 +90,7 @@ function renderWordLevelContent( if (change.removed) { // Highlight removed words with darker red segments.push( - + {change.value} ); @@ -93,7 +102,7 @@ function renderWordLevelContent( if (change.added) { // Highlight added words with darker green segments.push( - + {change.value} ); @@ -174,12 +183,12 @@ export const ColoredDiff: React.FC<{ diffContent: string }> = ({ switch (line.type) { case "add": gutterNumStr = (line.newLine ?? "").toString(); - backgroundColor = "green"; + backgroundColor = COLORS.ADDITION_BG; prefixSymbol = "+"; break; case "del": gutterNumStr = (line.oldLine ?? "").toString(); - backgroundColor = "red"; + backgroundColor = COLORS.DELETION_BG; prefixSymbol = "-"; break; case "context": @@ -193,7 +202,7 @@ export const ColoredDiff: React.FC<{ diffContent: string }> = ({ return ( - {gutterNumStr.padEnd(4)} + {gutterNumStr.padEnd(4)} {prefixSymbol}{" "} @@ -212,20 +221,20 @@ export const ColoredDiff: React.FC<{ diffContent: string }> = ({ return ( - + {(delLines[0]?.oldLine ?? "").toString().padEnd(4)}{" "} - - - + - + {renderWordLevelContent(oldContent, newContent, "removed")} - + {(addLines[0]?.newLine ?? "").toString().padEnd(4)}{" "} - + - + + + {renderWordLevelContent(oldContent, newContent, "added")}