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

load Pkg when hitting Pkg repl history #51921

Closed
Closed
Changes from all 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
9 changes: 5 additions & 4 deletions stdlib/REPL/src/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ const PKG_PROMPT = "pkg> "
const SHELL_PROMPT = "shell> "
const HELP_PROMPT = "help?> "

const Pkg_pkgid = Base.PkgId(Base.UUID("44cfe95a-1eb2-52ea-b672-e2afdf69b78f"), "Pkg")

mutable struct REPLBackend
"channel for AST"
repl_channel::Channel{Any}
Expand Down Expand Up @@ -249,7 +251,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) && Base.require_stdlib(Base.PkgId(Base.UUID("44cfe95a-1eb2-52ea-b672-e2afdf69b78f"), "Pkg"))
isempty(install_packages_hooks) && Base.require_stdlib(Pkg_pkgid)
for f in install_packages_hooks
Base.invokelatest(f, mods) && return
end
Expand Down Expand Up @@ -780,7 +782,7 @@ function history_move(s::Union{LineEdit.MIState,LineEdit.PrefixSearchState}, his
hist.last_mode = nothing
hist.last_buffer = IOBuffer()
else
if haskey(hist.mode_mapping, hist.modes[idx])
if haskey(hist.mode_mapping, hist.modes[idx]) || (hist.modes[idx] == :pkg && !isnothing(Base.require_stdlib(Pkg_pkgid)))
LineEdit.transition(s, hist.mode_mapping[hist.modes[idx]]) do
LineEdit.replace_line(s, hist.history[idx])
end
Expand Down Expand Up @@ -1193,8 +1195,7 @@ function setup_interface(
end,
']' => function (s::MIState,o...)
if isempty(s) || position(LineEdit.buffer(s)) == 0
pkgid = Base.PkgId(Base.UUID("44cfe95a-1eb2-52ea-b672-e2afdf69b78f"), "Pkg")
REPLExt = Base.require_stdlib(pkgid, "REPLExt")
REPLExt = Base.require_stdlib(Pkg_pkgid, "REPLExt")
pkg_mode = nothing
if REPLExt isa Module && isdefined(REPLExt, :PkgCompletionProvider)
for mode in repl.interface.modes
Expand Down