-
Notifications
You must be signed in to change notification settings - Fork 88
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 input key reading #712
Conversation
df1cac5
to
2d80784
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.
This is a great simplification!
lib/reline/key_stroke.rb
Outdated
end | ||
input[idx + 1] ? :unmatched : input[idx] ? :matched : :matching | ||
input[idx + 1] ? UNMATCHED : input[idx] ? MATCHED : MATCHING |
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.
nit: can we please expand this, my brain isn't good enough to process nested ternary operators 😅
One test is failing (fails building native extension while installing io/console). I think it is not related to this change. Passed job
Failed job
Same commit, same ruby version, different runner image verision. |
(ruby/reline#712) * Add key binding matching status :matching_matched * Simplify read_2nd_character * Add a comment of matching status and EOF * Matching status to a constant * Expand complicated ternary operators to case-when ruby/reline@64deec100b
Simplify input key reading
Depends on #709
Second step of #708
We don't need complex
read_2nd_character_of_key_sequence
andread_escaped_key
.This source code commend is partially right (only for ESC keys), but not correct.
Background
With this inputrc file
Input
ab
is:matched
and also:matching
(part ofabcd
). In this case, Readline waits for keyseq-timeout milliseconds.Input
abc
is:matching
(part ofabcd
). In this case, Readline waits forever.It's not ESC specific nor 2nd-char specific.
Changes
:matching_matched
forKeyStroke#match_status
.matching_matched ? keyseq_timeout : Infinity
.