@@ -75,6 +75,7 @@ class Core
75
75
76
76
def initialize
77
77
self . output = STDOUT
78
+ @mutex = Mutex . new
78
79
@dialog_proc_list = { }
79
80
yield self
80
81
@completion_quote_character = nil
@@ -254,44 +255,48 @@ def get_screen_size
254
255
Reline ::DEFAULT_DIALOG_CONTEXT = Array . new
255
256
256
257
def readmultiline ( prompt = '' , add_hist = false , &confirm_multiline_termination )
257
- unless confirm_multiline_termination
258
- raise ArgumentError . new ( '#readmultiline needs block to confirm multiline termination' )
259
- end
258
+ @mutex . synchronize do
259
+ unless confirm_multiline_termination
260
+ raise ArgumentError . new ( '#readmultiline needs block to confirm multiline termination' )
261
+ end
260
262
261
- Reline . update_iogate
262
- io_gate . with_raw_input do
263
- inner_readline ( prompt , add_hist , true , &confirm_multiline_termination )
264
- end
263
+ Reline . update_iogate
264
+ io_gate . with_raw_input do
265
+ inner_readline ( prompt , add_hist , true , &confirm_multiline_termination )
266
+ end
265
267
266
- whole_buffer = line_editor . whole_buffer . dup
267
- whole_buffer . taint if RUBY_VERSION < '2.7'
268
- if add_hist and whole_buffer and whole_buffer . chomp ( "\n " ) . size > 0
269
- Reline ::HISTORY << whole_buffer
270
- end
268
+ whole_buffer = line_editor . whole_buffer . dup
269
+ whole_buffer . taint if RUBY_VERSION < '2.7'
270
+ if add_hist and whole_buffer and whole_buffer . chomp ( "\n " ) . size > 0
271
+ Reline ::HISTORY << whole_buffer
272
+ end
271
273
272
- if line_editor . eof?
273
- line_editor . reset_line
274
- # Return nil if the input is aborted by C-d.
275
- nil
276
- else
277
- whole_buffer
274
+ if line_editor . eof?
275
+ line_editor . reset_line
276
+ # Return nil if the input is aborted by C-d.
277
+ nil
278
+ else
279
+ whole_buffer
280
+ end
278
281
end
279
282
end
280
283
281
284
def readline ( prompt = '' , add_hist = false )
282
- Reline . update_iogate
283
- io_gate . with_raw_input do
284
- inner_readline ( prompt , add_hist , false )
285
- end
285
+ @mutex . synchronize do
286
+ Reline . update_iogate
287
+ io_gate . with_raw_input do
288
+ inner_readline ( prompt , add_hist , false )
289
+ end
286
290
287
- line = line_editor . line . dup
288
- line . taint if RUBY_VERSION < '2.7'
289
- if add_hist and line and line . chomp ( "\n " ) . size > 0
290
- Reline ::HISTORY << line . chomp ( "\n " )
291
- end
291
+ line = line_editor . line . dup
292
+ line . taint if RUBY_VERSION < '2.7'
293
+ if add_hist and line and line . chomp ( "\n " ) . size > 0
294
+ Reline ::HISTORY << line . chomp ( "\n " )
295
+ end
292
296
293
- line_editor . reset_line if line_editor . line . nil?
294
- line
297
+ line_editor . reset_line if line_editor . line . nil?
298
+ line
299
+ end
295
300
end
296
301
297
302
private def inner_readline ( prompt , add_hist , multiline , &confirm_multiline_termination )
0 commit comments