diff options
author | aycabta <aycabta@gmail.com> | 2019-05-14 02:39:40 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2019-05-14 14:11:28 +0900 |
commit | 602ef62ae693344aea70a85bb664bbbe93f20465 (patch) | |
tree | f8aceed46bc1ff1a976c5cddd25c1ca5d1bdb6c0 /lib | |
parent | 5bab1304af25a843728dbcd2f3594913740aecb0 (diff) | |
download | ruby-602ef62ae693344aea70a85bb664bbbe93f20465.tar.gz |
Rescue CompatibilityError for Readline's completion
Diffstat (limited to 'lib')
-rw-r--r-- | lib/reline/line_editor.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 50f11f6480..86fc4d9bba 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -411,8 +411,13 @@ class Reline::LineEditor return nil end completed = list.inject { |memo, item| - memo_mbchars = memo.unicode_normalize.grapheme_clusters - item_mbchars = item.unicode_normalize.grapheme_clusters + begin + memo_mbchars = memo.unicode_normalize.grapheme_clusters + item_mbchars = item.unicode_normalize.grapheme_clusters + rescue Encoding::CompatibilityError + memo_mbchars = memo.grapheme_clusters + item_mbchars = item.grapheme_clusters + end size = [memo_mbchars.size, item_mbchars.size].min result = '' size.times do |i| |