diff options
author | aycabta <aycabta@gmail.com> | 2020-09-05 21:13:47 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2020-09-12 08:35:52 +0900 |
commit | 2e34b35a0ff7c326d1260a7f4dd3e4a9febe3d12 (patch) | |
tree | 1eeb83164a33a865176802cf3f5e9105da763486 /lib/reline/ansi.rb | |
parent | a840ef85690281a92b62e2d0dd84f7de69cfd4ae (diff) |
[ruby/reline] Skip the nil obtained from getc
The nil means there is nothing in the buffer in some systems. Incidentally,
Errno::EIO is raised if the I/O is closed.
https://github.com/ruby/reline/commit/c698634e74
Diffstat (limited to 'lib/reline/ansi.rb')
-rw-r--r-- | lib/reline/ansi.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/reline/ansi.rb b/lib/reline/ansi.rb index d2c32898b3..8b6b10cb89 100644 --- a/lib/reline/ansi.rb +++ b/lib/reline/ansi.rb @@ -65,7 +65,9 @@ class Reline::ANSI unless @@buf.empty? return @@buf.shift end - c = @@input.raw(intr: true, &:getbyte) + until c = @@input.raw(intr: true, &:getbyte) + sleep 0.1 + end (c == 0x16 && @@input.raw(min: 0, tim: 0, &:getbyte)) || c rescue Errno::EIO # Maybe the I/O has been closed. @@ -112,7 +114,9 @@ class Reline::ANSI @@input.raw do |stdin| @@output << "\e[6n" @@output.flush - while (c = stdin.getc) + loop do + c = stdin.getc + next if c.nil? res << c m = res.match(/\e\[(?<row>\d+);(?<column>\d+)R/) break if m |