Skip to content

Commit daa65cd

Browse files
committed
Ignore any encoding errors while symbol completion
1 parent 360c9c3 commit daa65cd

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/irb/completion.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def self.retrieve_completion_data(input, bind: IRB.conf[:MAIN_CONTEXT].workspace
192192
sym = $1
193193
candidates = Symbol.all_symbols.collect do |s|
194194
":" + s.id2name.encode(Encoding.default_external)
195-
rescue Encoding::UndefinedConversionError
195+
rescue EncodingError
196196
# ignore
197197
end
198198
candidates.grep(/^#{Regexp.quote(sym)}/)

test/irb/test_completion.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ def test_complete_numeric
2727
end
2828

2929
def test_complete_symbol
30+
%w"UTF-16LE UTF-7".each do |enc|
31+
"K".force_encoding(enc).to_sym
32+
rescue
33+
end
3034
_ = :aiueo
3135
assert_include(IRB::InputCompletor.retrieve_completion_data(":a", bind: binding), ":aiueo")
3236
assert_empty(IRB::InputCompletor.retrieve_completion_data(":irb_unknown_symbol_abcdefg", bind: binding))

0 commit comments

Comments
 (0)