Skip to content

Commit

Permalink
Fix Encoding::CompatibilityError: Shift_JIS is not compatible with UTF-8
Browse files Browse the repository at this point in the history
Error: test_completion_append_character(Reline::KeyActor::EmacsTest): Encoding::CompatibilityError: Shift_JIS is not compatible with UTF-8
/home/runner/work/reline/reline/lib/reline/line_editor.rb:814:in 'block in Reline::LineEditor#filter_normalize_candidates'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:808:in 'Array#select'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:808:in 'Reline::LineEditor#filter_normalize_candidates'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:831:in 'Reline::LineEditor#perform_completion'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1434:in 'Reline::LineEditor#complete'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:961:in 'Method#call'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:961:in 'Reline::LineEditor#wrap_method_call'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1029:in 'block in Reline::LineEditor#process_key'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:932:in 'Reline::LineEditor#run_for_operators'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1028:in 'Reline::LineEditor#process_key'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1051:in 'Reline::LineEditor#normal_char'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1089:in 'Reline::LineEditor#input_key'
/home/runner/work/reline/reline/test/reline/helper.rb:124:in 'block in Reline::TestCase#input_keys'
/home/runner/work/reline/reline/test/reline/helper.rb:117:in 'Array#each'
/home/runner/work/reline/reline/test/reline/helper.rb:117:in 'Reline::TestCase#input_keys'
/home/runner/work/reline/reline/test/reline/test_key_actor_emacs.rb:948:in 'Reline::KeyActor::EmacsTest#test_completion_append_character'
===============================================================================
===============================================================================
Error: test_continuous_completion_disabled_with_perfect_match(Reline::KeyActor::EmacsTest): Encoding::CompatibilityError: Shift_JIS is not compatible with UTF-8
/home/runner/work/reline/reline/lib/reline/line_editor.rb:814:in 'block in Reline::LineEditor#filter_normalize_candidates'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:808:in 'Array#select'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:808:in 'Reline::LineEditor#filter_normalize_candidates'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:831:in 'Reline::LineEditor#perform_completion'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1434:in 'Reline::LineEditor#complete'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:961:in 'Method#call'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:961:in 'Reline::LineEditor#wrap_method_call'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1029:in 'block in Reline::LineEditor#process_key'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:932:in 'Reline::LineEditor#run_for_operators'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1028:in 'Reline::LineEditor#process_key'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1051:in 'Reline::LineEditor#normal_char'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1089:in 'Reline::LineEditor#input_key'
/home/runner/work/reline/reline/test/reline/helper.rb:124:in 'block in Reline::TestCase#input_keys'
/home/runner/work/reline/reline/test/reline/helper.rb:117:in 'Array#each'
/home/runner/work/reline/reline/test/reline/helper.rb:117:in 'Reline::TestCase#input_keys'
/home/runner/work/reline/reline/test/reline/test_key_actor_emacs.rb:936:in 'Reline::KeyActor::EmacsTest#test_continuous_completion_disabled_with_perfect_match'
===============================================================================
===============================================================================
Error: test_continuous_completion_with_perfect_match(Reline::KeyActor::EmacsTest): Encoding::CompatibilityError: Shift_JIS is not compatible with UTF-8
/home/runner/work/reline/reline/lib/reline/line_editor.rb:814:in 'block in Reline::LineEditor#filter_normalize_candidates'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:808:in 'Array#select'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:808:in 'Reline::LineEditor#filter_normalize_candidates'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:831:in 'Reline::LineEditor#perform_completion'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1434:in 'Reline::LineEditor#complete'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:961:in 'Method#call'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:961:in 'Reline::LineEditor#wrap_method_call'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1029:in 'block in Reline::LineEditor#process_key'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:932:in 'Reline::LineEditor#run_for_operators'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1028:in 'Reline::LineEditor#process_key'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1051:in 'Reline::LineEditor#normal_char'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1089:in 'Reline::LineEditor#input_key'
/home/runner/work/reline/reline/test/reline/helper.rb:124:in 'block in Reline::TestCase#input_keys'
/home/runner/work/reline/reline/test/reline/helper.rb:117:in 'Array#each'
/home/runner/work/reline/reline/test/reline/helper.rb:117:in 'Reline::TestCase#input_keys'
/home/runner/work/reline/reline/test/reline/test_key_actor_emacs.rb:924:in 'Reline::KeyActor::EmacsTest#test_continuous_completion_with_perfect_match'
===============================================================================
Finished in 2.118582151 seconds.
385 tests, 1762 assertions, 0 failures, 3 errors, 0 pendings, 3 omissions, 0 notifications
  • Loading branch information
ima1zumi committed Nov 28, 2024
1 parent ab20545 commit a3026b1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -807,11 +807,13 @@ def editing_mode
target = target.downcase if @config.completion_ignore_case
list.select do |item|
next unless item

unless Encoding.compatible?(target.encoding, item.encoding)
# Crash with Encoding::CompatibilityError is required by readline-ext/test/readline/test_readline.rb
# TODO: fix the test
raise Encoding::CompatibilityError, "#{target.encoding.name} is not compatible with #{item.encoding.name}"
# Workaround for Readline test
if defined?(::Readline) && ::Readline == ::Reline
raise Encoding::CompatibilityError, "incompatible character encodings: #{target.encoding} and #{item.encoding}"
end

next item
end

if @config.completion_ignore_case
Expand Down

0 comments on commit a3026b1

Please sign in to comment.