Skip to content

Commit 75474fa

Browse files
committed
workaround wrong paths reported for stdlib functions in less and edit
1 parent e9a375a commit 75474fa

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

stdlib/InteractiveUtils/src/editless.jl

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ function edit(path::AbstractString, line::Integer=0)
8484
nothing
8585
end
8686

87+
# Workaround for https://github.com/JuliaLang/julia/issues/26314
88+
const BUILDBOT_STDLIB_PATH = dirname(abspath(joinpath(functionloc(eval)[1]), "..", "..", ".."))
89+
function functionloc_stdlib_workaround(args...)
90+
loc, line = functionloc(args...)
91+
if loc !== nothing
92+
loc = replace(loc, BUILDBOT_STDLIB_PATH => Sys.STDLIB)
93+
end
94+
return loc, line
95+
end
96+
8797
"""
8898
edit(function, [types])
8999
edit(module)
@@ -98,8 +108,8 @@ method to edit. For modules, open the main source file. The module needs to be l
98108
The editor can be changed by setting `JULIA_EDITOR`, `VISUAL` or `EDITOR` as an environment
99109
variable.
100110
"""
101-
edit(f) = edit(functionloc(f)...)
102-
edit(f, @nospecialize t) = edit(functionloc(f,t)...)
111+
edit(f) = edit(functionloc_stdlib_workaround(f)...)
112+
edit(f, @nospecialize t) = edit(functionloc_stdlib_workaround(f,t)...)
103113
edit(file, line::Integer) = error("could not find source file for function")
104114
edit(m::Module) = edit(pathof(m))
105115

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

0 commit comments

Comments
 (0)