julia icon indicating copy to clipboard operation
julia copied to clipboard

`define_editor` should default to `wait=true`

Open jyn514 opened this issue 1 year ago • 1 comments

(i want to prefix this by saying @miguelraz describes all my bugs as "your setup stuff is in like the .000001% of germs that pure alcohol doesn’t kill neighborhood")


define_editor in editless.jl has the following comment: https://github.com/JuliaLang/julia/blob/083bd8f687bb2a0608a1b0b4c99f811eecb56b3e/stdlib/InteractiveUtils/src/editless.jl#L49-L51

the comment is accurate; define_editor is defined as function define_editor(fn::Function, pattern; wait::Bool=false). this is a really weird default. using @edit with any unrecognized terminal editor will freeze the repl indefinitely; there are also weirder bugs like https://github.com/JuliaLang/julia/issues/53321.

why was this default chosen? i think wait=true is a much better default; almost all editors either wait, if they run in the terminal, or exit almost immediately if they open a window (e.g. code, xdg-open).

steps to replicate

  1. echo 'exec "$EDITOR" "$@"' > my-editor
  2. chmod +x my-editor
  3. JULIA_EDITOR=./my-editor julia
  4. @edit ""[1]
  5. the REPL freezes indefinitely. you have to kill it, e.g. with ctrl-z. even worse, if you manage to exit the editor (since it has taken over stdin, and most likely switched the terminal into canonical mode), signals will not be handled correctly, and you will need to kill it from another terminal, since this one is completely unresponsive.

meta info

julia> versioninfo()
Julia Version 1.9.1
Commit 147bdf428cd (2023-06-07 08:27 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 16 × AMD Ryzen 7 7700X 8-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, znver3)
  Threads: 1 on 16 virtual cores
Environment:
  JULIA_EDITOR = hx-hax

i installed julia through apt on popOS, which claims julia is Version: 1.9.1pop1~1686756697~22.04~8c30437

jyn514 avatar Aug 25 '24 13:08 jyn514

note that there are actually two defaults here: the default for the define_editor function, which is meant to be called in startup.jl, and the default for the fallback code which is run when EDITOR isn't recognized: https://github.com/JuliaLang/julia/blob/083bd8f687bb2a0608a1b0b4c99f811eecb56b3e/stdlib/InteractiveUtils/src/editless.jl#L121-L125 i care more strongly about the latter than the former.

jyn514 avatar Aug 25 '24 13:08 jyn514