The ^Q
shortcut lets a user jump to a source code line corresponding to a method or stackframe. It is just awesome. (It makes Julia a bit more like [the good parts of] SmallTalk)
What about a non-shortcut way to access the behavior? This would be useful if that shortcut doesn’t work for some reason (e.g. by default in VS Code), and could also possibly help with discoverability.
The current design remembers what was last displayed, and that information can be accessed in Base.active_repl.last_shown_line_infos
. That structure is uniform whether what was displayed was a Base.MethodList
or a a stacktrace via showerror
.
What about a design that stores directly a Base.MethodList
or a Vector{Base.StackTraces.StackFrame}
?* Combined with a definition like
edit(sf::StackTraces.StackFrame) = edit(sf.file, sf.line)
and
getindex
defined on Base.MethodList
It should then work out to do something like edit(Base.active_repl.last_shown[index])
.
As an additional benefit, this could be a way to get the last stacktrace, which I often want to e.g. copy it to my clipboard.
*It’s not as simple as remembering in show_backtrace
, but instead remembering in show_reduced_backtrace
and show_full_backtrace
. If the former is used, then Base.active_repl.last_shown
should be bound to displayed_stackframes
. This also means that there are two possible notions of the most recent stackframe…