Skip to content

Commit

Permalink
Merge pull request #3367 from julia-vscode/sp/active_module
Browse files Browse the repository at this point in the history
feat: support for REPL module switching
  • Loading branch information
pfitzseb committed Jul 29, 2023
2 parents cbaa60c + f14437c commit 2166284
Showing 1 changed file with 8 additions and 2 deletions.
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

0 comments on commit 2166284

Please sign in to comment.