Skip to content

Commit e42f546

Browse files
committed
Completely remove the use of Timeout
Timeout's implementation relies on Thread, which would conflict with `ruby/debug`'s thread-freezing implementation and has casued issues like - ruby/debug#877 - ruby/debug#934 - ruby/debug#1000 This commit avoids the issue by completely removing the use of Timeout.
1 parent 1412cac commit e42f546

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

lib/reline.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ def readline(prompt = '', add_hist = false)
396396
private def read_io(keyseq_timeout, &block)
397397
buffer = []
398398
loop do
399-
c = io_gate.getc
399+
c = io_gate.getc(Float::INFINITY)
400400
if c == -1
401401
result = :unmatched
402402
@bracketed_paste_finished = true

lib/reline/ansi.rb

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
require 'io/console'
22
require 'io/wait'
3-
require 'timeout'
43
require_relative 'terminfo'
54

65
class Reline::ANSI
@@ -154,7 +153,8 @@ def self.with_raw_input
154153
end
155154

156155
@@buf = []
157-
def self.inner_getc(count = 10)
156+
# a single count is 0.1 sec
157+
def self.inner_getc(count)
158158
unless @@buf.empty?
159159
return @@buf.shift
160160
end
@@ -174,17 +174,17 @@ def self.inner_getc(count = 10)
174174
@@in_bracketed_paste_mode = false
175175
START_BRACKETED_PASTE = String.new("\e[200~,", encoding: Encoding::ASCII_8BIT)
176176
END_BRACKETED_PASTE = String.new("\e[200~.", encoding: Encoding::ASCII_8BIT)
177-
def self.getc_with_bracketed_paste
177+
def self.getc_with_bracketed_paste(count)
178178
buffer = String.new(encoding: Encoding::ASCII_8BIT)
179-
buffer << inner_getc
179+
buffer << inner_getc(count)
180180
while START_BRACKETED_PASTE.start_with?(buffer) or END_BRACKETED_PASTE.start_with?(buffer) do
181181
if START_BRACKETED_PASTE == buffer
182182
@@in_bracketed_paste_mode = true
183-
return inner_getc
183+
return inner_getc(count)
184184
elsif END_BRACKETED_PASTE == buffer
185185
@@in_bracketed_paste_mode = false
186186
ungetc(-1)
187-
return inner_getc
187+
return inner_getc(count)
188188
end
189189
succ_c = inner_getc(Reline.core.config.keyseq_timeout)
190190

@@ -197,14 +197,14 @@ def self.getc_with_bracketed_paste
197197
buffer.bytes.reverse_each do |ch|
198198
ungetc ch
199199
end
200-
inner_getc
200+
inner_getc(count)
201201
end
202202

203-
def self.getc
203+
def self.getc(count)
204204
if Reline.core.config.enable_bracketed_paste
205-
getc_with_bracketed_paste
205+
getc_with_bracketed_paste(count)
206206
else
207-
inner_getc
207+
inner_getc(count)
208208
end
209209
end
210210

lib/reline/general_io.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def self.with_raw_input
3434
yield
3535
end
3636

37-
def self.getc
37+
def self.getc(_count)
3838
unless @@buf.empty?
3939
return @@buf.shift
4040
end

lib/reline/windows.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def self.with_raw_input
295295
yield
296296
end
297297

298-
def self.getc
298+
def self.getc(_)
299299
check_input_event
300300
@@output_buf.shift
301301
end

0 commit comments

Comments
 (0)