Skip to content

Commit

Permalink
workaround wrong paths reported for stdlib functions in less and edit
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC committed Aug 2, 2019
1 parent e9a375a commit 75474fa
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions stdlib/InteractiveUtils/src/editless.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ function edit(path::AbstractString, line::Integer=0)
nothing
end

# Workaround for https://github.com/JuliaLang/julia/issues/26314
const BUILDBOT_STDLIB_PATH = dirname(abspath(joinpath(functionloc(eval)[1]), "..", "..", ".."))
function functionloc_stdlib_workaround(args...)
loc, line = functionloc(args...)
if loc !== nothing
loc = replace(loc, BUILDBOT_STDLIB_PATH => Sys.STDLIB)
end
return loc, line
end

"""
edit(function, [types])
edit(module)
Expand All @@ -98,8 +108,8 @@ method to edit. For modules, open the main source file. The module needs to be l
The editor can be changed by setting `JULIA_EDITOR`, `VISUAL` or `EDITOR` as an environment
variable.
"""
edit(f) = edit(functionloc(f)...)
edit(f, @nospecialize t) = edit(functionloc(f,t)...)
edit(f) = edit(functionloc_stdlib_workaround(f)...)
edit(f, @nospecialize t) = edit(functionloc_stdlib_workaround(f,t)...)
edit(file, line::Integer) = error("could not find source file for function")
edit(m::Module) = edit(pathof(m))

Expand Down Expand Up @@ -134,6 +144,6 @@ less(file::AbstractString) = less(file, 1)
Show the definition of a function using the default pager, optionally specifying a tuple of
types to indicate which method to see.
"""
less(f) = less(functionloc(f)...)
less(f, @nospecialize t) = less(functionloc(f,t)...)
less(f) = less(functionloc_stdlib_workaround(f)...)
less(f, @nospecialize t) = less(functionloc_stdlib_workaround(f,t)...)
less(file, line::Integer) = error("could not find source file for function")

0 comments on commit 75474fa

Please sign in to comment.