MCPcopy Create free account
hub / github.com/modem-dev/hunk / resolveWordDiffHighlightBg

Function resolveWordDiffHighlightBg

src/ui/diff/pierre.ts:289–301  ·  view source on GitHub ↗

Resolve one word-diff background without turning transparent surfaces into black blends.

(contentBg: string, lineBg: string, signColor: string)

Source from the content-addressed store, hash-verified

287
288/** Resolve one word-diff background without turning transparent surfaces into black blends. */
289function resolveWordDiffHighlightBg(contentBg: string, lineBg: string, signColor: string) {
290 if (contentBg === TRANSPARENT_BACKGROUND || lineBg === TRANSPARENT_BACKGROUND) {
291 return contentBg;
292 }
293
294 if (!isHexThemeColor(contentBg) || !isHexThemeColor(lineBg)) {
295 return contentBg;
296 }
297
298 return hexColorDistance(contentBg, lineBg) >= MIN_WORD_DIFF_BG_DISTANCE
299 ? contentBg
300 : strengthenWordDiffBg(lineBg, signColor);
301}
302
303/** Resolve the inline word-diff background, strengthening theme colors that are too subtle to see. */
304function wordDiffHighlightBg(kind: SplitLineCell["kind"], theme: AppTheme) {

Callers 1

wordDiffHighlightBgFunction · 0.85

Calls 3

hexColorDistanceFunction · 0.90
isHexThemeColorFunction · 0.85
strengthenWordDiffBgFunction · 0.85

Tested by

no test coverage detected