Skip to content

Commit

Permalink
REPL: precompile in a throwaway module because Main is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Sep 12, 2024
1 parent 945517b commit 7402bbb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions stdlib/REPL/src/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -758,11 +758,11 @@ setmodifiers!(c::REPLCompletionProvider, m::LineEdit.Modifiers) = c.modifiers =
Set `mod` as the default contextual module in the REPL,
both for evaluating expressions and printing them.
"""
function activate(mod::Module=Main)
function activate(mod::Module=Main; interactive_utils::Bool=true)
mistate = (Base.active_repl::LineEditREPL).mistate
mistate === nothing && return nothing
mistate.active_module = mod
Base.load_InteractiveUtils(mod)
interactive_utils && Base.load_InteractiveUtils(mod)
return nothing
end

Expand Down
3 changes: 3 additions & 0 deletions stdlib/REPL/src/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ let
DOWN_ARROW = "\e[B"

repl_script = """
module ThrowAway end
import REPL
REPL.activate(ThrowAway; interactive_utils=false) # Main is closed so we can't evaluate in it
2+2
print("")
printstyled("a", "b")
Expand Down

0 comments on commit 7402bbb

Please sign in to comment.