MCPcopy Create free account
hub / github.com/JanSmrcka/differ / RenderDiff

Function RenderDiff

internal/ui/diff.go:149–161  ·  view source on GitHub ↗

RenderDiff renders parsed diff lines into a styled string.

(parsed ParsedDiff, filename string, styles Styles, t theme.Theme, width int)

Source from the content-addressed store, hash-verified

147
148// RenderDiff renders parsed diff lines into a styled string.
149func RenderDiff(parsed ParsedDiff, filename string, styles Styles, t theme.Theme, width int) string {
150 if parsed.Binary {
151 return RenderBinaryFile(styles, width)
152 }
153 initChromaStyle(t.ChromaStyle)
154
155 var b strings.Builder
156 for _, dl := range parsed.Lines {
157 b.WriteString(renderDiffLine(dl, filename, styles, t, width))
158 b.WriteByte('\n')
159 }
160 return b.String()
161}
162
163func renderDiffLine(dl DiffLine, filename string, styles Styles, t theme.Theme, width int) string {
164 switch dl.Type {

Callers 4

loadDiffCmdMethod · 0.85
TestRenderDiff_BasicFunction · 0.85
TestRenderDiff_BinaryFunction · 0.85
renderCommitDiffFunction · 0.85

Calls 3

RenderBinaryFileFunction · 0.85
initChromaStyleFunction · 0.85
renderDiffLineFunction · 0.85

Tested by 2

TestRenderDiff_BasicFunction · 0.68
TestRenderDiff_BinaryFunction · 0.68