mirror of
https://github.com/mum4k/termdash.git
synced 2025-04-28 13:48:51 +08:00
faketerm.Diff also prints out the rune differences.
Useful when they aren't obvious in their character forms.
This commit is contained in:
parent
286ab5c504
commit
486172e4f9
@ -54,6 +54,7 @@ func Diff(want, got *Terminal) string {
|
||||
|
||||
size := got.Size()
|
||||
var optDiffs []*optDiff
|
||||
cellsDiffer := false
|
||||
for row := 0; row < size.Y; row++ {
|
||||
for col := 0; col < size.X; col++ {
|
||||
p := image.Point{col, row}
|
||||
@ -67,6 +68,7 @@ func Diff(want, got *Terminal) string {
|
||||
r := gotCell.Rune
|
||||
if r != wantCell.Rune {
|
||||
r = '࿃'
|
||||
cellsDiffer = true
|
||||
} else if r == 0 && !partial {
|
||||
r = ' '
|
||||
}
|
||||
@ -91,5 +93,16 @@ func Diff(want, got *Terminal) string {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if cellsDiffer {
|
||||
b.WriteString(" Found differences in some of the cell runes:\n")
|
||||
for row := 0; row < size.Y; row++ {
|
||||
for col := 0; col < size.X; col++ {
|
||||
got := got.BackBuffer()[col][row].Rune
|
||||
want := want.BackBuffer()[col][row].Rune
|
||||
b.WriteString(fmt.Sprintf(" cell(%v, %v) => got '%c' (rune %d), want '%c' (rune %d)", col, row, got, got, want, want))
|
||||
}
|
||||
}
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user