-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor utf-8 strings and invalid strings in test code #800
Conversation
private def convert_str(input, options = {}, normalized = nil) | ||
return nil if input.nil? | ||
input = input.chars.map { |c| | ||
if Reline::Unicode::EscapedChars.include?(c.ord) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reline::Unicode::EscapedChars
is no longer use. Could you remove it?
Line 37 in 72c0ec0
EscapedChars = EscapedPairs.keys.map(&:chr) |
~/ghq/github.com/ruby/reline test_rm_invalid_encoding
❯ git grep EscapedChars
lib/reline/unicode.rb: EscapedChars = EscapedPairs.keys.map(&:chr)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed 👍
I also added two more commits that removes \M-[char]
from test_within_pipe.rb
and from test_rendering.rb
…sed code/arg/options
yamatanooroti handles invalid byte sequence input "\M-[char]" and converts it to "\e[char]" We don't need to use these invalid byte sequence and rely on the hack implemented in yamatanooroti
38300af
to
c7b8dac
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
code (ruby/reline#800) * Remove invalid encoding string "\M-[char]" from test code, remove unused code/arg/options * Omit unicode unnoralized input test in non-utf8 testcase * Remove helper method and constant no longer used in testcode * Change key binding test to use realistic bytes instead of invalid byte sequence * Remove invalid byte sequence input from rendering test yamatanooroti handles invalid byte sequence input "\M-[char]" and converts it to "\e[char]" We don't need to use these invalid byte sequence and rely on the hack implemented in yamatanooroti ruby/reline@f09e7b154c
This pull request resolves the problem mentioned in the source code comment in input_keys.
"\M-[char]"
should be removed from test code because it is an invalid byte sequence string.Reline only accepts
"\e[char]"
which is sent byMeta-[char]
key input in modern terminal emulators.After invalid byte sequence are removed, we don't need
convert
option in methodinput_keys
because valid strings does not need to skip convert.Other changes
def convert_str(input)
can be simpler.If the input needs
unicode_normalize
before conversion, then the prerequisites of the test (input unicode-unnormalized text) are broken. We just need to omit the test if the test encoding is not utf-8.