MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / renderContent

Function renderContent

webview-ui/src/components/common/DiffView.tsx:144–168  ·  view source on GitHub ↗
(line: DiffLine, hunk: Hunk, lineIndexInHunk: number)

Source from the content-addressed store, hash-verified

142
143 // Render helper that uses precomputed highlighting
144 const renderContent = (line: DiffLine, hunk: Hunk, lineIndexInHunk: number): React.ReactNode => {
145 if (!shouldHighlight || !hunk.highlightedOldLines || !hunk.highlightedNewLines) {
146 return line.content
147 }
148
149 // Find the line index within the old/new text for this hunk
150 const hunkLinesBeforeThis = hunk.lines.slice(0, lineIndexInHunk).filter((l) => l.type !== "gap")
151
152 if (line.type === "deletion") {
153 // Count deletions and context lines before this line
154 const oldLineIndex = hunkLinesBeforeThis.filter((l) => l.type === "deletion" || l.type === "context").length
155 return hunk.highlightedOldLines[oldLineIndex] || line.content
156 } else if (line.type === "addition") {
157 // Count additions and context lines before this line
158 const newLineIndex = hunkLinesBeforeThis.filter((l) => l.type === "addition" || l.type === "context").length
159 return hunk.highlightedNewLines[newLineIndex] || line.content
160 } else if (line.type === "context") {
161 // For context lines, prefer new-side highlighting, fall back to old-side
162 const newLineIndex = hunkLinesBeforeThis.filter((l) => l.type === "addition" || l.type === "context").length
163 const oldLineIndex = hunkLinesBeforeThis.filter((l) => l.type === "deletion" || l.type === "context").length
164 return hunk.highlightedNewLines[newLineIndex] || hunk.highlightedOldLines[oldLineIndex] || line.content
165 }
166
167 return line.content
168 }
169
170 return (
171 <div className="diff-view bg-[var(--vscode-editor-background)] rounded-md overflow-hidden text-[0.95em]">

Callers 1

DiffView.tsxFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected