Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source paths found by @searchmethods not correct #3

Open
asampal opened this issue Nov 21, 2018 · 1 comment
Open

Source paths found by @searchmethods not correct #3

asampal opened this issue Nov 21, 2018 · 1 comment

Comments

@asampal
Copy link

asampal commented Nov 21, 2018

Using Windows 10, VSCode REPL

Trying to invoke @searchmethods 1 returns the following:

image

I'm not sure where the source paths for the results are obtained from, but they aren't on my system.

@tkf
Copy link
Owner

tkf commented Nov 21, 2018

This is actually an issue in julia. @edit and @less also have the same problem: JuliaLang/julia#26314

I tried to workaround the problem by guessing the right location:

"""
find_source_file(file)
Find source `file` and return its full path. It just calls
`Base.find_source_file` and return its result for normal Julia
installation. For nightly Julia build, it tries to guess the right
path when `Base.find_source_file` failed.
"""
function find_source_file(file)
path = Base.find_source_file(file)
if path isa AbstractString && ! isfile(path)
for m in methods(Pkg.add)
exfile = try
String(m.file)
catch err
continue
end
idx = findlast(joinpath(Base.Filesystem.path_separator,
"share", "julia"), exfile)
if idx isa Nothing
continue
end
prefix = exfile[1:idx[1]]
if startswith(file, prefix)
# e.g., relpath = "share/julia/stdlib/v0.7/..."
relpath = file[length(prefix)+1:end]
return joinpath(Base.Sys.BINDIR, "..", relpath)
end
end
end
return path
end

This happens after you choose the path in the interactive matcher. So you'll see the wrong paths, but you may get the correct file in the editor after you hit enter.

But I only tested it in Linux so it may not work in Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants