Skip to content

Commit bfd53fd

Browse files
MilesCranmervtjnash
authored andcommitted
Make edit(f) return methods if multiple signatures available (JuliaLang#39481)
Co-authored-by: Jameson Nash <[email protected]>
1 parent bac57ab commit bfd53fd

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

stdlib/InteractiveUtils/src/editless.jl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,16 @@ method to edit. For modules, open the main source file. The module needs to be l
222222
To ensure that the file can be opened at the given line, you may need to call
223223
`define_editor` first.
224224
"""
225-
edit(f) = edit(functionloc(f)...)
226-
edit(f, @nospecialize t) = edit(functionloc(f,t)...)
227-
edit(file, line::Integer) = error("could not find source file for function")
225+
function edit(@nospecialize f)
226+
ms = methods(f).ms
227+
length(ms) == 1 && edit(functionloc(ms[1])...)
228+
length(ms) > 1 && return ms
229+
length(ms) == 0 && functionloc(f) # throws
230+
nothing
231+
end
232+
edit(@nospecialize(f), idx::Integer) = edit(methods(f).ms[idx])
233+
edit(f, t) = (@nospecialize; edit(functionloc(f, t)...))
234+
edit(file::Nothing, line::Integer) = error("could not find source file for function")
228235
edit(m::Module) = edit(pathof(m))
229236

230237
# terminal pager

0 commit comments

Comments
 (0)