From c633fc953d1c193953ed851317db87b737b5c0e8 Mon Sep 17 00:00:00 2001 From: Daniel Wennberg Date: Mon, 12 Aug 2024 15:37:45 +0200 Subject: [PATCH] Distinguish stdout and display contexts, see #2727 --- src/runner/PlutoRunner/src/PlutoRunner.jl | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/runner/PlutoRunner/src/PlutoRunner.jl b/src/runner/PlutoRunner/src/PlutoRunner.jl index 366fa63181..d39ec94aa3 100644 --- a/src/runner/PlutoRunner/src/PlutoRunner.jl +++ b/src/runner/PlutoRunner/src/PlutoRunner.jl @@ -1007,10 +1007,17 @@ const default_iocontext = IOContext(devnull, :pluto_with_js_link => (io, callback, on_cancellation) -> core_with_js_link(io, callback, on_cancellation), ) +# `stdout` mimics a TTY, the only relevant property is :color const default_stdout_iocontext = IOContext(devnull, - :color => true, - :limit => true, - :displaysize => (18, 75), + :color => true, + :is_pluto => false, +) + +# `display` sees a richer context like in the REPL, see #2727 +const default_display_iocontext = IOContext(devnull, + :color => true, + :limit => true, + :displaysize => (18, 75), :is_pluto => false, ) @@ -2826,7 +2833,7 @@ function with_io_to_logs(f::Function; enabled::Bool=true, loglevel::Logging.LogL end # To make the `display` function work. - redirect_display = TextDisplay(pe_stdout) + redirect_display = TextDisplay(IOContext(pe_stdout, default_display_iocontext)) pushdisplay(redirect_display) # Run the function `f`, capturing all output that it might have generated.