File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 "fmt"
66 "log"
77 "os"
8+ "regexp"
89 "strings"
910
1011 "io/ioutil"
@@ -82,6 +83,7 @@ func summarizeDiff(diffs []diffmatchpatch.Diff) *FileDiff {
8283 const maxShowLine = 3
8384 const omissionText = "...\n "
8485 lastDiffIdx := len (diffs ) - 1
86+ spaceRegexp := regexp .MustCompile (`\s` )
8587
8688 for i , diff := range diffs {
8789 text := diff .Text
@@ -92,7 +94,7 @@ func summarizeDiff(diffs []diffmatchpatch.Diff) *FileDiff {
9294 writeString (& builder , ansiGreen + text + ansiReset )
9395 fileDiff .numInsert += len (text )
9496 case diffmatchpatch .DiffDelete :
95- writeString (& builder , ansiRed + text + ansiReset )
97+ writeString (& builder , ansiRed + regexp . QuoteMeta ( spaceRegexp . ReplaceAllString ( text , "␣" )) + ansiReset )
9698 fileDiff .numDelete += len (text )
9799 case diffmatchpatch .DiffEqual :
98100 var showHead , showTail bool
You can’t perform that action at this time.
0 commit comments