mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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.
This commit is contained in:
parent
d39be242ba
commit
7a7854d8c1
1 changed files with 10 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue