From 87f8958a218215df0aaffab59736c30eb6f51d2e Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Fri, 27 Jan 2023 14:53:04 +0100 Subject: [PATCH] Store the frontend task object in the REPL struct. (#48400) --- stdlib/REPL/src/REPL.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/stdlib/REPL/src/REPL.jl b/stdlib/REPL/src/REPL.jl index e3912a48df429..b2eb8cf63c8da 100644 --- a/stdlib/REPL/src/REPL.jl +++ b/stdlib/REPL/src/REPL.jl @@ -389,6 +389,7 @@ end mutable struct BasicREPL <: AbstractREPL terminal::TextTerminal waserror::Bool + frontend_task::Task BasicREPL(t) = new(t, false) end @@ -396,6 +397,7 @@ outstream(r::BasicREPL) = r.terminal hascolor(r::BasicREPL) = hascolor(r.terminal) function run_frontend(repl::BasicREPL, backend::REPLBackendRef) + repl.frontend_task = current_task() d = REPLDisplay(repl) dopushdisplay = !in(d,Base.Multimedia.displays) dopushdisplay && pushdisplay(d) @@ -462,6 +464,7 @@ mutable struct LineEditREPL <: AbstractREPL last_shown_line_infos::Vector{Tuple{String,Int}} interface::ModalInterface backendref::REPLBackendRef + frontend_task::Task function LineEditREPL(t,hascolor,prompt_color,input_color,answer_color,shell_color,help_color,history_file,in_shell,in_help,envcolors) opts = Options() opts.hascolor = hascolor @@ -1281,6 +1284,7 @@ function setup_interface( end function run_frontend(repl::LineEditREPL, backend::REPLBackendRef) + repl.frontend_task = current_task() d = REPLDisplay(repl) dopushdisplay = repl.specialdisplay === nothing && !in(d,Base.Multimedia.displays) dopushdisplay && pushdisplay(d) @@ -1306,6 +1310,7 @@ mutable struct StreamREPL <: AbstractREPL input_color::String answer_color::String waserror::Bool + frontend_task::Task StreamREPL(stream,pc,ic,ac) = new(stream,pc,ic,ac,false) end StreamREPL(stream::IO) = StreamREPL(stream, Base.text_colors[:green], Base.input_color(), Base.answer_color()) @@ -1364,6 +1369,7 @@ ends_with_semicolon(code::Union{String,SubString{String}}) = contains(_rm_strings_and_comments(code), r";\s*$") function run_frontend(repl::StreamREPL, backend::REPLBackendRef) + repl.frontend_task = current_task() have_color = hascolor(repl) Base.banner(repl.stream) d = REPLDisplay(repl)