[前][次][番号順一覧][スレッド一覧]

ruby-changes:61201

From: aycabta <ko1@a...>
Date: Tue, 12 May 2020 02:55:05 +0900 (JST)
Subject: [ruby-changes:61201] 7a7854d8c1 (master): Some I/O in test doesn't have "position"

https://git.ruby-lang.org/ruby.git/commit/?id=7a7854d8c1

From 7a7854d8c18b0ec15b3c050aff179f9753a44210 Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Tue, 12 May 2020 00:51:47 +0900
Subject: 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.

diff --git a/lib/reline/ansi.rb b/lib/reline/ansi.rb
index 3ef02d6..91f4cee 100644
--- a/lib/reline/ansi.rb
+++ b/lib/reline/ansi.rb
@@ -116,9 +116,16 @@ class Reline::ANSI https://github.com/ruby/ruby/blob/trunk/lib/reline/ansi.rb#L116
       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
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]