From ba605b821e99f5cdf00ec78147333855853fd7a4 Mon Sep 17 00:00:00 2001 From: Chris Foster Date: Thu, 13 Jan 2022 13:13:08 +1000 Subject: [PATCH] Bugfix: record current eval module on client side (#32) This makes sure the client remembers the current module so that reconnecting works. --- src/client.jl | 5 ++++- test/runtests.jl | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/client.jl b/src/client.jl index ae45b01..935777d 100644 --- a/src/client.jl +++ b/src/client.jl @@ -273,7 +273,7 @@ function run_remote_repl_command(conn, out_stream, cmdstr) # Help mode cmd = (:help, magic[2]) elseif magic[1] == "%module" - mod_ex = parse_input(magic[2]) + mod_ex = Meta.parse(magic[2]) cmd = (:in_module, mod_ex) end end @@ -285,6 +285,9 @@ function run_remote_repl_command(conn, out_stream, cmdstr) result_for_display = Text(value) end end + if messageid == :in_module + conn.in_module = mod_ex + end else @error "Unexpected response from server" messageid end diff --git a/test/runtests.jl b/test/runtests.jl index 38f9b54..cef7d1e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -147,6 +147,9 @@ try end""") @test runcommand("%module TestMod") == "Evaluating commands in module Main.TestMod" @test runcommand("var_in_test_mod") == "123" + # Artificially force a reconnect so we can test that the current module is remembered + close(conn.socket) + @test runcommand("var_in_test_mod") == "123" # Test that show() on the remote side uses the eval module as the context # module in the show IOContext @test runcommand("SomeStruct") == "SomeStruct"