Skip to content

Commit

Permalink
No right-pad on method list printing
Browse files Browse the repository at this point in the history
  • Loading branch information
Liozou committed Mar 4, 2022
1 parent cac5d16 commit 7bbfe0b
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions base/methodshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -340,40 +340,28 @@ function show_method_list_header(io::IO, ms::MethodList, namefmt::Function)
nothing
end

function _print_compact_positions(io, last_position, last_num, len)
s = string(last_position)
print(io, s)
len += length(s) + 1
function _print_compact_positions(io, last_position, last_num)
print(io, last_position)
if last_position != last_num
print(io, '-')
s = string(last_num)
len += length(s) + 1
print(io, s)
print(io, '-', last_num)
end
return len
end

function print_compact_positions(io, positions, maxposlen)
function print_compact_positions(io, positions)
print(io, '[')
last_position = last_num = positions[1]
len = 3
for i in 2:length(positions)
p = positions[i]
if p == last_num + 1
last_num = p
continue
end
len = _print_compact_positions(io, last_position, last_num, len)
_print_compact_positions(io, last_position, last_num)
print(io, ',')
last_position = last_num = p
end
len = _print_compact_positions(io, last_position, last_num, len) - 1
_print_compact_positions(io, last_position, last_num)
print(io, "] ")
if maxposlen > len
print(io, ' '^(maxposlen - len))
len = maxposlen
end
return len
end

function show_method_table(io::IO, ml::Union{MethodList,FactoredMethodList}, max::Int=-1, header::Bool=true)
Expand All @@ -390,13 +378,12 @@ function show_method_table(io::IO, ml::Union{MethodList,FactoredMethodList}, max

last_shown_line_infos = get(io, :last_shown_line_infos, nothing)
last_shown_line_infos === nothing || empty!(last_shown_line_infos)
maxposlen = 0

for (n, meth) in (ml isa FactoredMethodList ? zip(ml.positions, ml.list) : enumerate(ml.ms))
if max == -1 || n[1] < max
println(io)
if ml isa FactoredMethodList
maxposlen = print_compact_positions(io, sort(n), maxposlen)
print_compact_positions(io, sort(n))
else
print(io, "[$n] ")
end
Expand Down

0 comments on commit 7bbfe0b

Please sign in to comment.