summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2021-02-18 03:41:47 +0900
committeraycabta <aycabta@gmail.com>2021-02-21 06:44:05 +0900
commitaeac4ddcc0de536c0ecdea29e01dd2505e32f6ae (patch)
tree7b554395544b81fcb1a4522e8f16c69de849201a
parent38d30a6942babb815bcd05b035fc58a7e13dd717 (diff)
[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
-rw-r--r--lib/reline/line_editor.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index 0adda72b23..12a2bde234 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -344,8 +344,9 @@ class Reline::LineEditor
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