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

feat: support for REPL module switching #3367

Merged
merged 1 commit into from
Jul 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions scripts/packages/VSCodeServer/src/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ function install_vscode_shell_integration(prompt)
end
end

if VERSION > v"1.9-"
active_module = Base.active_module
else
active_module() = Main
end

const HAS_REPL_TRANSFORM = Ref{Bool}(false)
function hook_repl(repl)
if HAS_REPL_TRANSFORM[]
Expand Down Expand Up @@ -150,7 +156,7 @@ function hook_repl(repl)

main_mode.on_done = REPL.respond(repl, main_mode; pass_empty = false) do line
quote
$(evalrepl)(Main, $line, $repl, $main_mode)
$(evalrepl)($(active_module)(), $line, $repl, $main_mode)
end
end
@debug "legacy REPL hook installed"
Expand All @@ -160,7 +166,7 @@ end

function transform_backend(ast, repl, main_mode)
quote
$(evalrepl)(Main, $(QuoteNode(ast)), $repl, $main_mode)
$(evalrepl)($(active_module)(), $(QuoteNode(ast)), $repl, $main_mode)
end
end

Expand Down