Skip to content

Commit ddda4ba

Browse files
committed
Fix trailing newline in diff display. Update test references.
1 parent 24247d0 commit ddda4ba

File tree

7 files changed

+33
-37
lines changed

7 files changed

+33
-37
lines changed

src/CodeDiff.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ Base.show(io::IO, ::MIME"text/plain", diff::CodeDiff) = side_by_side_diff(io, di
6161
function Base.show(io::IO, diff::CodeDiff)
6262
xlines = split(diff.before, '\n')
6363
ylines = split(diff.after, '\n')
64-
DeepDiffs.visitall(diff) do idx, state, last
64+
is_first = true
65+
DeepDiffs.visitall(diff) do idx, state, _
66+
!is_first && println(io)
6567
if state === :removed
6668
printstyled(io, "- ", xlines[idx], color=:red)
6769
elseif state === :added
@@ -75,7 +77,7 @@ function Base.show(io::IO, diff::CodeDiff)
7577
else
7678
print(io, " ", xlines[idx])
7779
end
78-
!last && println(io)
80+
is_first = false
7981
end
8082
end
8183

src/compare.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ For code types with no option to control the verbosity of the output, `dbinfo` i
332332
ignored.
333333
334334
```julia
335-
# Default comparison
335+
# Default display
336336
@code_for type=:native f()
337337
338338
# Without debuginfo

src/display.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,9 @@ function side_by_side_diff(io::IO, diff::CodeDiff; tab_width=4, width=nothing, l
231231
end
232232
end
233233

234-
DeepDiffs.visitall(diff) do idx, state, last
234+
is_first = true
235+
DeepDiffs.visitall(diff) do idx, state, _
236+
!is_first && println(io)
235237
if state === :removed
236238
print_line_num(:left)
237239
print_columns(io, column_width, xlines[idx], sep_removed, "", empty_column, tab)
@@ -249,7 +251,7 @@ function side_by_side_diff(io::IO, diff::CodeDiff; tab_width=4, width=nothing, l
249251
print_columns(io, column_width, xlines[idx], sep_same, xlines[idx], empty_column, tab)
250252
print_line_num(:right)
251253
end
252-
!last && println(io)
254+
is_first = false
253255
end
254256
end
255257

test/references/a_vs_b.jl_ast

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
quote ┃ quote
2-
┣⟫ println("B")
3-
1 + 2 ⟪╋⟫ 1 + 3
4-
f(a, b) ⟪╋⟫ f(a, d)
5-
g(c, d) ⟪╋⟫ g(c, b)
6-
┣⟫ h(x, y)
7-
"test" ⟪╋⟫ "test2"
8-
end ┃ end
1+
┣⟫println("B")
2+
1 + 2 ⟪╋⟫1 + 3
3+
f(a, b) ⟪╋⟫f(a, d)
4+
g(c, d) ⟪╋⟫g(c, b)
5+
┣⟫h(x, y)
6+
"test" ⟪╋⟫"test2"
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
quote  ┃ quote
2-
  ┣⟫ println("B")
3-
 1 + 2 ⟪╋⟫ 1 + 3
4-
 f(a, b) ⟪╋⟫ f(a, d)
5-
 g(c, d) ⟪╋⟫ g(c, b)
6-
  ┣⟫ h(x, y)
7-
 "test" ⟪╋⟫ "test2"
8-
end  ┃ end
1+
  ┣⟫println("B")
2+
1 + 2 ⟪╋⟫1 + 3
3+
f(a, b) ⟪╋⟫f(a, d)
4+
g(c, d) ⟪╋⟫g(c, b)
5+
  ┣⟫h(x, y)
6+
"test" ⟪╋⟫"test2"
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
1 quote ┃ quote 1
2-
┣⟫ println("B") 2
3-
2 1 + 2 ⟪╋⟫ 1 + 3 3
4-
3 f(a, b) ⟪╋⟫ f(a, d) 4
5-
4 g(c, d) ⟪╋⟫ g(c, b) 5
6-
┣⟫ h(x, y) 6
7-
5 "test" ⟪╋⟫ "test2" 7
8-
6 end ┃ end 8
1+
┣⟫println("B") 1
2+
1 1 + 2 ⟪╋⟫1 + 3 2
3+
2 f(a, b) ⟪╋⟫f(a, d) 3
4+
3 g(c, d) ⟪╋⟫g(c, b) 4
5+
┣⟫h(x, y) 5
6+
4 "test" ⟪╋⟫"test2" 6
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
quote
2-
+ println("B")
3-
~ 1 + {-2-}{+3+}
4-
~ f(a, {-b-}{+d+})
5-
~ g(c, {-d-}{+b+})
6-
+ h(x, y)
7-
~ "test{+2+}"
8-
end
1+
+ println("B")
2+
~ 1 + {-2-}{+3+}
3+
~ f(a, {-b-}{+d+})
4+
~ g(c, {-d-}{+b+})
5+
+ h(x, y)
6+
~ "test{+2+}"

0 commit comments

Comments
 (0)