Skip to content

Commit

Permalink
[ruby/reline] Use UTF-8 only for width calc, rest uses original encoding
Browse files Browse the repository at this point in the history
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.

ruby/reline@44596c0cc7
  • Loading branch information
aycabta committed Feb 20, 2021
1 parent 38d30a6 commit aeac4dd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/reline/line_editor.rb
Expand Up @@ -344,8 +344,9 @@ def multiline_off
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
Expand Down

0 comments on commit aeac4dd

Please sign in to comment.