Skip to content

Commit

Permalink
only run on lines starting with using/import to avoid re-running no…
Browse files Browse the repository at this point in the history
…n-load code
  • Loading branch information
IanButterworth committed Mar 13, 2021
1 parent 6c69b34 commit 149afd8
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions stdlib/REPL/src/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -785,18 +785,26 @@ function eval_with_backend(ast, backend::REPLBackendRef)
if last(resp)
err = first(first(first(resp)))
if err isa ModuleNotFoundError
for f in install_package_hooks
if f(err.mod)
put!(backend.repl_channel, (ast, 1))
resp = take!(backend.response_channel) # (val, iserr)
break
end
end
handle_install_package_hooks(err.mod, ast, backend)
end
end
return resp
end

function handle_install_package_hooks(mod, ast, backend)
line = string(ast.args[2])
# only exercise hooks for lines starting with `using/import` to avoid re-running non-load code
if startswith(line, "using") || startswith(line, "import")
for f in install_package_hooks
if f(mod)
put!(backend.repl_channel, (ast, 1))
resp = take!(backend.response_channel) # (val, iserr)
return
end
end
end
end

function respond(f, repl, main; pass_empty::Bool = false, suppress_on_semicolon::Bool = true)
return function do_respond(s::MIState, buf, ok::Bool)
if !ok
Expand Down

0 comments on commit 149afd8

Please sign in to comment.