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

ruby-changes:65312

From: aycabta <ko1@a...>
Date: Sun, 21 Feb 2021 07:04:18 +0900 (JST)
Subject: [ruby-changes:65312] aeac4ddcc0 (master): [ruby/reline] Use UTF-8 only for width calc, rest uses original encoding

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

From aeac4ddcc0de536c0ecdea29e01dd2505e32f6ae Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Thu, 18 Feb 2021 03:41:47 +0900
Subject: [ruby/reline] Use UTF-8 only for width calc, rest uses original
 encoding

I confirmed that libvterm supports only which are UTF-8, US ASCII, UK, and
DEC graphics by reading source code, so can't test this patch by
yamatanoorogi gem through vterm gem for now.

This fixes ruby/irb#190.

https://github.com/ruby/reline/commit/44596c0cc7
---
 lib/reline/line_editor.rb | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index 0adda72..12a2bde 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -344,8 +344,9 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L344
     else
     end_of_line_cursor = new_cursor_max
     end
-    line_to_calc.encode(Encoding::UTF_8).grapheme_clusters.each do |gc|
-      mbchar_width = Reline::Unicode.get_mbchar_width(gc)
+    line_to_calc.grapheme_clusters.each do |gc|
+      mbchar = gc.encode(Encoding::UTF_8)
+      mbchar_width = Reline::Unicode.get_mbchar_width(mbchar)
       now = new_cursor + mbchar_width
       if now > end_of_line_cursor or now > cursor
         break
-- 
cgit v1.1


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

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