1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Check encoding when Readline completion

This commit is contained in:
aycabta 2019-05-14 04:08:23 +09:00
parent 29dde62605
commit 1e65196b54
2 changed files with 10 additions and 2 deletions

View file

@ -405,7 +405,10 @@ class Reline::LineEditor
private def complete_internal_proc(list, is_menu)
preposing, target, postposing = @retrieve_completion_block.(@line, @byte_pointer)
list = list.select { |i| i&.start_with?(target) }
list = list.select { |i|
raise Encoding::CompatibilityError if i and i.encoding != @encoding
i&.start_with?(target)
}
if is_menu
menu(target, list)
return nil

View file

@ -4,8 +4,9 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
def setup
@prompt = '> '
@config = Reline::Config.new # Emacs mode is default
@encoding = (RELINE_TEST_ENCODING rescue Encoding.default_external)
@line_editor = Reline::LineEditor.new(@config)
@line_editor.reset(@prompt, (RELINE_TEST_ENCODING rescue Encoding.default_external))
@line_editor.reset(@prompt, @encoding)
@line_editor.retrieve_completion_block = Reline.method(:retrieve_completion_block)
end
@ -1054,6 +1055,8 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
foo_bar
foo_baz
qux
}.map { |i|
i.encode(@encoding)
}
}
input_keys('fo')
@ -1096,6 +1099,8 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
foo_bar
foo_baz
qux
}.map { |i|
i.encode(@encoding)
}
}
input_keys('abcde fo ABCDE')