Repository navigation
Improve key binding match/matching check - #709
Merged
Merged
Conversation
tompng
force-pushed
the
key_binding_algorithm
branch
from
May 29, 2024 17:23
a6a180a to
119950b
Compare
tompng
force-pushed
the
key_binding_algorithm
branch
from
June 2, 2024 07:39
119950b to
265959e
Compare
st0012
reviewed
Jun 2, 2024
| @@ -19,20 +19,10 @@ module Reline | |||
| class ConfigEncodingConversionError < StandardError; end | |||
|
|
|||
| Key = Struct.new(:char, :combined_char, :with_meta) do | |||
Member
There was a problem hiding this comment.
nit: can we also convert this into a normal class?
st0012
reviewed
Jun 2, 2024
|
|
||
| def add_oneshot_key_binding(keystroke, target) | ||
| @oneshot_key_bindings[keystroke] = target | ||
| # IRB sets invalid keystroke [Reline::Key]. We should ignore it. |
Member
Author
There was a problem hiding this comment.
Not yet.
Even if we remove it, we need to support [Reline::Key.new(nil, 0xE4, true)] for a while, not to break an environment that new Reline is installed but IRB is not updated.
Member
There was a problem hiding this comment.
Yes I'm aware of that and I'm not arguing we need to change the approach here 🙂 I just hadn't see any related PR on IRB so want to confirm.
…ymap internally Co-authored-by: Stan Lo <stan001212@gmail.com>
st0012
approved these changes
Jun 3, 2024
st0012
left a comment
Member
There was a problem hiding this comment.
I didn't test the changes manually, but they look good to me 👍
matzbot
pushed a commit
to ruby/ruby
that referenced
this pull request
Jun 3, 2024
(ruby/reline#709) * Improve key binding match/matching check * Rename key_actors to default_key_bindings * Make key_stroke.expand always return a value * Update add_default_key_binding to use a add_default_key_binding_by_keymap internally Co-authored-by: Stan Lo <stan001212@gmail.com> --------- ruby/reline@353ec236e2 Co-authored-by: Stan Lo <stan001212@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First step of #708
This will make
:matched:matchingcheck simple and fast, especially after we merge MAPPING(size==256 array) and key_bindings(small hash)Structure
Composite key binding
KeyStroke#expand
When key bindings is
{ 'abc' => :foo, 'ab' => :bar, 'xy' => :baz },abxyshould be[:bar, :baz].Old implementation will expand
abxto[Key(:bar), Key('x')]but it should beexpanded: [Key(:bar)], rest_bytes: ['x']. The rest bytesxcould be part ofxy.