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:
parent
29dde62605
commit
1e65196b54
2 changed files with 10 additions and 2 deletions
|
@ -405,7 +405,10 @@ class Reline::LineEditor
|
||||||
|
|
||||||
private def complete_internal_proc(list, is_menu)
|
private def complete_internal_proc(list, is_menu)
|
||||||
preposing, target, postposing = @retrieve_completion_block.(@line, @byte_pointer)
|
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
|
if is_menu
|
||||||
menu(target, list)
|
menu(target, list)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -4,8 +4,9 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
|
||||||
def setup
|
def setup
|
||||||
@prompt = '> '
|
@prompt = '> '
|
||||||
@config = Reline::Config.new # Emacs mode is default
|
@config = Reline::Config.new # Emacs mode is default
|
||||||
|
@encoding = (RELINE_TEST_ENCODING rescue Encoding.default_external)
|
||||||
@line_editor = Reline::LineEditor.new(@config)
|
@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)
|
@line_editor.retrieve_completion_block = Reline.method(:retrieve_completion_block)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1054,6 +1055,8 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
|
||||||
foo_bar
|
foo_bar
|
||||||
foo_baz
|
foo_baz
|
||||||
qux
|
qux
|
||||||
|
}.map { |i|
|
||||||
|
i.encode(@encoding)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
input_keys('fo')
|
input_keys('fo')
|
||||||
|
@ -1096,6 +1099,8 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
|
||||||
foo_bar
|
foo_bar
|
||||||
foo_baz
|
foo_baz
|
||||||
qux
|
qux
|
||||||
|
}.map { |i|
|
||||||
|
i.encode(@encoding)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
input_keys('abcde fo ABCDE')
|
input_keys('abcde fo ABCDE')
|
||||||
|
|
Loading…
Reference in a new issue