Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPL output prefix logic broken in history mode on 1.9 #49359

Closed
pfitzseb opened this issue Apr 14, 2023 · 0 comments · Fixed by #49383
Closed

REPL output prefix logic broken in history mode on 1.9 #49359

pfitzseb opened this issue Apr 14, 2023 · 0 comments · Fixed by #49383
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior REPL Julia's REPL (Read Eval Print Loop)

Comments

@pfitzseb
Copy link
Member

The output prefix logic in display(::REPLDisplay) assumes that the REPL is in normal mode, not in history mode.

This means that code like the following will fail

julia> @async begin
         try
           sleep(2)
           display(Base.Multimedia.displays[2], 2) # Base.Multimedia.displays[2] is the REPLDisplay for me
         catch err
           @error "cant display" ex=(err, catch_backtrace())
         end
       end
Task (runnable) @0x00007f0ed7f08fb0

julia> 1+1┌ Error: cant display
│   ex =
│    MethodError: no method matching write_output_prefix(::IOContext{Base.TTY}, ::REPL.LineEdit.PrefixHistoryPrompt, ::Bool)
│
│    Closest candidates are:
│      write_output_prefix(::IO, ::REPL.LineEdit.Prompt, ::Bool)
│       @ REPL ~/.julia/juliaup/julia-1.9.0-rc1+0.x64.linux.gnu/share/julia/stdlib/v1.9/REPL/src/LineEdit.jl:1472
│
│    Stacktrace:
│     [1] (::REPL.var"#55#56"{REPL.REPLDisplay{REPL.LineEditREPL}, MIME{Symbol("text/plain")}, Base.RefValue{Any}})(io::Any)
│       @ REPL ~/.julia/juliaup/julia-1.9.0-rc1+0.x64.linux.gnu/share/julia/stdlib/v1.9/REPL/src/REPL.jl:267
│     [2] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
│       @ REPL ~/.julia/juliaup/julia-1.9.0-rc1+0.x64.linux.gnu/share/julia/stdlib/v1.9/REPL/src/REPL.jl:555
│     [3] display(d::REPL.REPLDisplay, mime::MIME{Symbol("text/plain")}, x::Any)
│       @ REPL ~/.julia/juliaup/julia-1.9.0-rc1+0.x64.linux.gnu/share/julia/stdlib/v1.9/REPL/src/REPL.jl:262
│     [4] display
│       @ ~/.julia/juliaup/julia-1.9.0-rc1+0.x64.linux.gnu/share/julia/stdlib/v1.9/REPL/src/REPL.jl:279 [inlined]
│     [5] macro expansion
│       @ ./REPL[4]:4 [inlined]
│     [6] (::var"#5#6")()
│       @ Main ./task.jl:514
└ @ Main REPL[4]:6

when moving back in the REPL history after starting the async task. Here's an asciinema recording for illustration purposes.

@KristofferC KristofferC added bug Indicates an unexpected problem or unintended behavior REPL Julia's REPL (Read Eval Print Loop) labels Apr 14, 2023
@KristofferC KristofferC self-assigned this Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior REPL Julia's REPL (Read Eval Print Loop)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants