From 4685584c7f1324553710e2722534380a54420f7d Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Sat, 22 Jun 2024 11:56:07 -0400 Subject: [PATCH] make repl_mutate_lock global --- stdlib/REPL/src/LineEdit.jl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/stdlib/REPL/src/LineEdit.jl b/stdlib/REPL/src/LineEdit.jl index e881a65ca6b1c..f25f167855dfb 100644 --- a/stdlib/REPL/src/LineEdit.jl +++ b/stdlib/REPL/src/LineEdit.jl @@ -2845,12 +2845,14 @@ keymap_data(s::PromptState, prompt::Prompt) = prompt.repl keymap(ms::MIState, m::ModalInterface) = keymap(state(ms), mode(ms)) keymap_data(ms::MIState, m::ModalInterface) = keymap_data(state(ms), mode(ms)) +# should be locked when adding/editing a repl mode etc. +const repl_mutate_lock = Base.ReentrantLock() + function prompt!(term::TextTerminal, prompt::ModalInterface, s::MIState = init_state(term, prompt)) Base.reseteof(term) - l = Base.ReentrantLock() t1 = Threads.@spawn :interactive while true wait(s.async_channel) - status = @lock l begin + status = @lock repl_mutate_lock begin fcn = take!(s.async_channel) fcn(s) end @@ -2865,7 +2867,7 @@ function prompt!(term::TextTerminal, prompt::ModalInterface, s::MIState = init_s # and we want to not block typing when the repl task thread is busy t2 = Threads.@spawn :interactive while true eof(term) || peek(term) # wait before locking but don't consume - @lock l begin + @lock repl_mutate_lock begin kmap = keymap(s, prompt) fcn = match_input(kmap, s) kdata = keymap_data(s, prompt)