Skip to content

Commit

Permalink
Ignore any encoding errors while symbol completion
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Sep 23, 2021
1 parent 360c9c3 commit daa65cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/irb/completion.rb
Expand Up @@ -192,7 +192,7 @@ def self.retrieve_completion_data(input, bind: IRB.conf[:MAIN_CONTEXT].workspace
sym = $1
candidates = Symbol.all_symbols.collect do |s|
":" + s.id2name.encode(Encoding.default_external)
rescue Encoding::UndefinedConversionError
rescue EncodingError
# ignore
end
candidates.grep(/^#{Regexp.quote(sym)}/)
Expand Down
4 changes: 4 additions & 0 deletions test/irb/test_completion.rb
Expand Up @@ -27,6 +27,10 @@ def test_complete_numeric
end

def test_complete_symbol
%w"UTF-16LE UTF-7".each do |enc|
"K".force_encoding(enc).to_sym
rescue
end
_ = :aiueo
assert_include(IRB::InputCompletor.retrieve_completion_data(":a", bind: binding), ":aiueo")
assert_empty(IRB::InputCompletor.retrieve_completion_data(":irb_unknown_symbol_abcdefg", bind: binding))
Expand Down

0 comments on commit daa65cd

Please sign in to comment.