summaryrefslogtreecommitdiff
path: root/lib/reline
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2020-05-12 00:51:47 +0900
committeraycabta <aycabta@gmail.com>2020-05-12 02:53:44 +0900
commit7a7854d8c18b0ec15b3c050aff179f9753a44210 (patch)
tree06149a326e50fb0643447cf55c514f50337a7206 /lib/reline
parentd39be242ba795e34c1907c4d88329b15ad2838bd (diff)
Some I/O in test doesn't have "position"
Just returns column 1 for ambiguous width because this I/O is not tty and can't seek.
Diffstat (limited to 'lib/reline')
-rw-r--r--lib/reline/ansi.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/reline/ansi.rb b/lib/reline/ansi.rb
index 3ef02d6e7a..91f4cee3c7 100644
--- a/lib/reline/ansi.rb
+++ b/lib/reline/ansi.rb
@@ -116,9 +116,16 @@ class Reline::ANSI
column = m[:column].to_i - 1
row = m[:row].to_i - 1
rescue Errno::ENOTTY
- buf = @@output.pread(@@output.pos, 0)
- row = buf.count("\n")
- column = buf.rindex("\n") ? (buf.size - buf.rindex("\n")) - 1 : 0
+ begin
+ buf = @@output.pread(@@output.pos, 0)
+ row = buf.count("\n")
+ column = buf.rindex("\n") ? (buf.size - buf.rindex("\n")) - 1 : 0
+ rescue Errno::ESPIPE
+ # Just returns column 1 for ambiguous width because this I/O is not
+ # tty and can't seek.
+ row = 0
+ column = 1
+ end
end
Reline::CursorPos.new(column, row)
end