@@ -416,6 +416,7 @@ function load_REPL()
416416end
417417
418418global active_repl
419+ global active_repl_backend = nothing
419420
420421function run_fallback_repl (interactive:: Bool )
421422 let input = stdin
@@ -455,6 +456,37 @@ function run_fallback_repl(interactive::Bool)
455456 end
456457 end
457458 end
459+ nothing
460+ end
461+
462+ function run_std_repl (REPL:: Module , quiet:: Bool , banner:: Symbol , history_file:: Bool )
463+ term_env = get (ENV , " TERM" , @static Sys. iswindows () ? " " : " dumb" )
464+ term = REPL. Terminals. TTYTerminal (term_env, stdin , stdout , stderr )
465+ banner == :no || REPL. banner (term, short= banner== :short )
466+ if term. term_type == " dumb"
467+ repl = REPL. BasicREPL (term)
468+ quiet || @warn " Terminal not fully functional"
469+ else
470+ repl = REPL. LineEditREPL (term, get (stdout , :color , false ), true )
471+ repl. history_file = history_file
472+ end
473+ # Make sure any displays pushed in .julia/config/startup.jl ends up above the
474+ # REPLDisplay
475+ d = REPL. REPLDisplay (repl)
476+ last_active_repl = @isdefined (active_repl) ? active_repl : nothing
477+ last_active_repl_backend = active_repl_backend
478+ global active_repl = repl
479+ pushdisplay (d)
480+ try
481+ global active_repl = repl
482+ _atreplinit (repl)
483+ REPL. run_repl (repl, backend-> (global active_repl_backend = backend))
484+ finally
485+ popdisplay (d)
486+ active_repl = last_active_repl
487+ active_repl_backend = last_active_repl_backend
488+ end
489+ nothing
458490end
459491
460492# run the requested sort of evaluation loop on stdio
@@ -469,24 +501,7 @@ function run_main_repl(interactive::Bool, quiet::Bool, banner::Symbol, history_f
469501 end
470502 REPL = REPL_MODULE_REF[]
471503 if ! fallback_repl && interactive && REPL != = Base
472- invokelatest (REPL) do REPL
473- term_env = get (ENV , " TERM" , @static Sys. iswindows () ? " " : " dumb" )
474- term = REPL. Terminals. TTYTerminal (term_env, stdin , stdout , stderr )
475- banner == :no || REPL. banner (term, short= banner== :short )
476- if term. term_type == " dumb"
477- repl = REPL. BasicREPL (term)
478- quiet || @warn " Terminal not fully functional"
479- else
480- repl = REPL. LineEditREPL (term, get (stdout , :color , false ), true )
481- repl. history_file = history_file
482- end
483- global active_repl = repl
484- # Make sure any displays pushed in .julia/config/startup.jl ends up above the
485- # REPLDisplay
486- pushdisplay (REPL. REPLDisplay (repl))
487- _atreplinit (repl)
488- REPL. run_repl (repl, backend-> (global active_repl_backend = backend))
489- end
504+ invokelatest (run_std_repl, REPL, quiet, banner, history_file)
490505 else
491506 if ! fallback_repl && interactive && ! quiet
492507 @warn " REPL provider not available: using basic fallback" LOAD_PATH = join (Base. LOAD_PATH , Sys. iswindows () ? ' ;' : ' :' )
0 commit comments