From 7bbfe0b79326fe354897ae31e3606d64ddeb8f1a Mon Sep 17 00:00:00 2001 From: Lionel Zoubritzky Date: Wed, 2 Mar 2022 00:10:14 +0100 Subject: [PATCH] No right-pad on method list printing --- base/methodshow.jl | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/base/methodshow.jl b/base/methodshow.jl index 46f7f2b75af24..8a33249f179b0 100644 --- a/base/methodshow.jl +++ b/base/methodshow.jl @@ -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) @@ -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