Skip to content

Commit 853060a

Browse files
Don't defer input evaluation to REPL backend (#376)
Co-authored-by: Kristoffer Carlsson <[email protected]>
1 parent b2cea53 commit 853060a

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/repl.jl

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,22 @@ function RunDebugger(frame, repl = nothing, terminal = nothing; initial_continue
169169
return state.overall_result
170170
end
171171

172+
@static if VERSION v"1.11.5"
173+
# Starting from https://github.com/JuliaLang/julia/pull/57773, `print_response`
174+
# hands over the evaluation to the backend using a `Channel` for synchronization.
175+
# However, this causes a deadlock for Debugger because we call this from the backend already.
176+
function print_response(repl, response, show_value::Bool, have_color::Bool)
177+
repl.waserror = response[2]
178+
backend = nothing # don't defer evaluation to the REPL backend, do it eagerly.
179+
REPL.with_repl_linfo(repl) do io
180+
io = IOContext(io, :module => Base.active_module(repl)::Module)
181+
182+
REPL.print_response(io, response, backend, show_value, have_color, REPL.specialdisplay(repl))
183+
end
184+
end
185+
else
186+
print_response(repl, response, show_value::Bool, have_color::Bool) = REPL.print_response(repl, response, show_value, have_color)
187+
end
172188

173189
function julia_prompt(state::DebuggerState)
174190
# Return early if this has already been called on the state
@@ -190,16 +206,7 @@ function julia_prompt(state::DebuggerState)
190206
end
191207
command = String(take!(buf))
192208
response = _eval_code(active_frame(state), command)
193-
@static if VERSION >= v"1.11.5"
194-
# Since https://github.com/JuliaLang/julia/pull/57773 REPL.print_resons runs `display` on the backend
195-
# task. If this is called from the same thread the channel orchestration will block, so do this async.
196-
fetch(Threads.@spawn REPL.print_response(state.repl, response, true, true))
197-
elseif VERSION >= v"1.2.0-DEV.253"
198-
REPL.print_response(state.repl, response, true, true)
199-
else
200-
ok, result = response
201-
REPL.print_response(state.repl, ok ? result : result[1], ok ? nothing : result[2], true, true)
202-
end
209+
print_response(state.repl, response, true, true)
203210
println(state.terminal)
204211
LineEdit.reset_state(s)
205212
end

0 commit comments

Comments
 (0)