@@ -114,7 +114,9 @@ Return the signatures of all methods whose definition spans the specified locati
114114Returns `nothing` if there are no methods at that location.
115115"""
116116function signatures_at(filename:: AbstractString , line:: Integer )
117- filename = abspath(filename)
117+ if ! startswith(filename, " REPL[" )
118+ filename = abspath(filename)
119+ end
118120 if occursin(juliabase, filename)
119121 rpath = postpath(filename, juliabase)
120122 id = PkgId(Base)
@@ -186,17 +188,18 @@ see [`definition(Expr, method::Method)`](@ref) instead.
186188"""
187189function definition(:: Type{String} , method:: Method )
188190 file, line = whereis(method)
189- src = read (file, String )
191+ src = src_from_file_or_REPL (file)
190192 eol = isequal(' \n ' )
191193 linestarts = Int[]
192- istart = 0
194+ istart = 1
193195 for i = 1 : line- 1
194- push!(linestarts, istart+ 1 )
195- istart = findnext(eol, src, istart+ 1 )
196+ push!(linestarts, istart)
197+ istart = findnext(eol, src, istart) + 1
196198 end
197199 ex, iend = Meta. parse(src, istart)
198200 if isfuncexpr(ex)
199- return src[istart+ 1 : iend- 1 ], line
201+ iend = min(iend, lastindex(src))
202+ return strip(src[istart: iend], ' \n ' ), line
200203 end
201204 # The function declaration was presumably on a previous line
202205 lineindex = lastindex(linestarts)
0 commit comments