Skip to content

Commit 127b21c

Browse files
committed
Made diffprettytext replace invisibles with unicode characters
1 parent 849d7eb commit 127b21c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

diffmatchpatch/diff.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,10 +1152,14 @@ func (dmp *DiffMatchPatch) DiffPrettyText(diffs []Diff) string {
11521152
switch diff.Type {
11531153
case DiffInsert:
11541154
_, _ = buff.WriteString("\x1b[32m")
1155+
text = strings.ReplaceAll(text, " ", "█")
1156+
text = strings.ReplaceAll(text, "\n", "⏎")
11551157
_, _ = buff.WriteString(text)
11561158
_, _ = buff.WriteString("\x1b[0m")
11571159
case DiffDelete:
11581160
_, _ = buff.WriteString("\x1b[31m")
1161+
text = strings.ReplaceAll(text, " ", "█")
1162+
text = strings.ReplaceAll(text, "\n", "⏎")
11591163
_, _ = buff.WriteString(text)
11601164
_, _ = buff.WriteString("\x1b[0m")
11611165
case DiffEqual:

0 commit comments

Comments
 (0)