Skip to content

Commit 569ebde

Browse files
authored
REPL: reference the global MIState as a LineEditREPL field (#24809)
1 parent 7d7d81a commit 569ebde

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

base/repl/LineEdit.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ abstract type ModeState end
1515
export run_interface, Prompt, ModalInterface, transition, reset_state, edit_insert, keymap
1616

1717
struct ModalInterface <: TextInterface
18-
modes::Array{Base.LineEdit.TextInterface,1}
18+
modes::Vector{TextInterface}
1919
end
2020

2121
mutable struct Prompt <: TextInterface
@@ -2166,8 +2166,8 @@ function init_state(terminal, m::ModalInterface)
21662166
s
21672167
end
21682168

2169-
function run_interface(terminal, m::ModalInterface)
2170-
s::MIState = init_state(terminal, m)
2169+
2170+
function run_interface(terminal::TextTerminal, m::ModalInterface, s::MIState=init_state(terminal, m))
21712171
while !s.aborted
21722172
buf, ok, suspend = prompt!(terminal, m, s)
21732173
while suspend
@@ -2251,7 +2251,7 @@ keymap_data(s::PromptState, prompt::Prompt) = prompt.repl
22512251
keymap(ms::MIState, m::ModalInterface) = keymap(state(ms), mode(ms))
22522252
keymap_data(ms::MIState, m::ModalInterface) = keymap_data(state(ms), mode(ms))
22532253

2254-
function prompt!(term, prompt, s = init_state(term, prompt))
2254+
function prompt!(term::TextTerminal, prompt::ModalInterface, s::MIState = init_state(term, prompt))
22552255
Base.reseteof(term)
22562256
raw!(term, true)
22572257
enable_bracketed_paste(term)

base/repl/REPL.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ import ..LineEdit:
3333
history_last,
3434
history_search,
3535
accept_result,
36-
terminal
36+
terminal,
37+
MIState
3738

3839
abstract type AbstractREPL end
3940

@@ -275,11 +276,12 @@ mutable struct LineEditREPL <: AbstractREPL
275276
waserror::Bool
276277
specialdisplay::Union{Void,AbstractDisplay}
277278
options::Options
279+
mistate::Union{MIState,Void}
278280
interface::ModalInterface
279281
backendref::REPLBackendRef
280282
LineEditREPL(t,hascolor,prompt_color,input_color,answer_color,shell_color,help_color,history_file,in_shell,in_help,envcolors) =
281283
new(t,true,prompt_color,input_color,answer_color,shell_color,help_color,history_file,in_shell,
282-
in_help,envcolors,false,nothing, Options())
284+
in_help,envcolors,false,nothing, Options(), nothing)
283285
end
284286
outstream(r::LineEditREPL) = r.t
285287
specialdisplay(r::LineEditREPL) = r.specialdisplay
@@ -987,7 +989,8 @@ function run_frontend(repl::LineEditREPL, backend::REPLBackendRef)
987989
interface = repl.interface
988990
end
989991
repl.backendref = backend
990-
run_interface(repl.t, interface)
992+
repl.mistate = LineEdit.init_state(terminal(repl), interface)
993+
run_interface(terminal(repl), interface, repl.mistate)
991994
dopushdisplay && popdisplay(d)
992995
end
993996

0 commit comments

Comments
 (0)