Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions stdlib/REPL/src/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,7 @@ function eval_user_input(@nospecialize(ast), backend::REPLBackend, mod::Module)
put!(backend.response_channel, Pair{Any, Bool}(lasterr, true))
else
backend.in_eval = true
if !isempty(install_packages_hooks)
check_for_missing_packages_and_run_hooks(ast)
end
check_for_missing_packages_and_run_hooks(ast)
for xf in backend.ast_transforms
ast = Base.invokelatest(xf, ast)
end
Expand All @@ -251,6 +249,7 @@ function check_for_missing_packages_and_run_hooks(ast)
mods = modules_to_be_loaded(ast)
filter!(mod -> isnothing(Base.identify_package(String(mod))), mods) # keep missing modules
if !isempty(mods)
isempty(install_packages_hooks) && load_pkg()
for f in install_packages_hooks
Base.invokelatest(f, mods) && return
end
Expand Down Expand Up @@ -1586,6 +1585,16 @@ function run_frontend(repl::StreamREPL, backend::REPLBackendRef)
nothing
end

function load_pkg()
Base.generating_output(true) && return nothing
pkgid = Base.PkgId(Base.UUID("44cfe95a-1eb2-52ea-b672-e2afdf69b78f"), "Pkg")
if Base.locate_package(pkgid) !== nothing # Only try load Pkg if we can find it
Pkg = Base.require(pkgid)
return Pkg
end
return nothing
end

module Numbered

using ..REPL
Expand Down Expand Up @@ -1658,7 +1667,6 @@ function __current_ast_transforms(backend)
end
end


function numbered_prompt!(repl::LineEditREPL=Base.active_repl, backend=nothing)
n = Ref{Int}(0)
set_prompt(repl, n)
Expand Down