Skip to content

Commit

Permalink
Bugfix: record current eval module on client side (#32)
Browse files Browse the repository at this point in the history
This makes sure the client remembers the current module so that
reconnecting works.
  • Loading branch information
c42f authored Jan 13, 2022
1 parent e73b929 commit ba605b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit ba605b8

Please sign in to comment.