From ada29c2f056cb3f5ee1b4f2cb8d14c44214ae8b4 Mon Sep 17 00:00:00 2001 From: Michael Abbott Date: Sun, 18 Oct 2020 14:18:49 +0200 Subject: [PATCH] bold function names in stacktrace --- base/show.jl | 11 ++++++----- base/stacktraces.jl | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/base/show.jl b/base/show.jl index dd04f1feb7dc65..d8dac951b05ac2 100644 --- a/base/show.jl +++ b/base/show.jl @@ -2028,7 +2028,7 @@ function show_signature_function(io::IO, @nospecialize(ft), demangle=false, farg if ft <: Function && isa(uw, DataType) && isempty(uw.parameters) && isdefined(uw.name.module, uw.name.mt.name) && ft == typeof(getfield(uw.name.module, uw.name.mt.name)) - print(io, (demangle ? demangle_function_name : identity)(uw.name.mt.name)) + print_within_stacktrace(io, (demangle ? demangle_function_name : identity)(uw.name.mt.name), bold=true) elseif isa(ft, DataType) && ft.name === Type.body.name && (f = ft.parameters[1]; !isa(f, TypeVar)) uwf = unwrap_unionall(f) @@ -2040,19 +2040,20 @@ function show_signature_function(io::IO, @nospecialize(ft), demangle=false, farg if html print(io, "($fargname::", ft, ")") else - print(io, "($fargname::", ft, ")") + print_within_stacktrace(io, "($fargname::", ft, ")", bold=true) end end nothing end -function print_within_stacktrace(io, s...; color, bold=false) +function print_within_stacktrace(io, s...; color=:normal, bold=false) if get(io, :backtrace, false)::Bool printstyled(io, s...; color, bold) else print(io, s...) end end + function show_tuple_as_call(io::IO, name::Symbol, sig::Type, demangle=false, kwargs=nothing, argnames=nothing) # print a method signature tuple for a lambda definition if sig === Tuple @@ -2091,7 +2092,7 @@ function show_tuple_as_call(io::IO, name::Symbol, sig::Type, demangle=false, kwa print_type_stacktrace(io, t) end end - print(io, ")") + print_within_stacktrace(io, ")", bold=true) show_method_params(io, tv) nothing end @@ -2099,7 +2100,7 @@ end function print_type_stacktrace(io, type; color=:normal) str = sprint(show, type, context=io) i = findfirst('{', str) - if isnothing(i) + if isnothing(i) || !get(io, :backtrace, false)::Bool printstyled(io, str; color=color) else printstyled(io, str[1:i-1]; color=color) diff --git a/base/stacktraces.jl b/base/stacktraces.jl index ec366b0def1985..9c51362318144a 100644 --- a/base/stacktraces.jl +++ b/base/stacktraces.jl @@ -217,7 +217,7 @@ function show_spec_linfo(io::IO, frame::StackFrame) elseif frame.func === top_level_scope_sym print(io, "top-level scope") else - print(io, Base.demangle_function_name(string(frame.func))) + Base.print_within_stacktrace(io, Base.demangle_function_name(string(frame.func)), bold=true) end elseif linfo isa MethodInstance def = linfo.def