-
Notifications
You must be signed in to change notification settings - Fork 86
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
Upward navigation through completion results not working as expected #675
Comments
I'm not sure if this is what recommended, but if I tweak my
That allows upward navigation to work in IRB without borking e.g. bash file autocompletion. I'm still fuzzy on where "completion-journey-up" comes from or whether configuration like I pasted above should be necessary navigate results in both directions. |
The issue arises because Reline does not support the setting for reline/lib/reline/line_editor.rb Line 1137 in d348df9
Reline should support configuring As a workaround, using |
I'd be happy to work on a PR for this to scratch my own itch, if that'd be valuable. It would help me to know if there are any similar examples in the codebase already for related configuration.
It does work, yes. 🙂 |
Thank you for your offer! In this case, probably we need to turn this part into a method. reline/lib/reline/line_editor.rb Lines 1137 to 1142 in d348df9
The reason is because Reline converts commands read from reline/lib/reline/line_editor.rb Lines 1533 to 1536 in d348df9
Similarly, for other commands, you can find them by converting hyphens in Readline commands to underscores. If you can't find it even after converting hyphens to underscores, it's likely not implemented. If you need to test, please refer to this file. It's a test using a testing framework called yamatanooroti. Here's how to run the tests: Feel free to ask me if you have any questions. |
Fixes ruby#675 This commit extracts the upward navigation condition in `LineEditor#input_key` to a new private method, and adds a new alias. This change allows Reline to support upward navigation in when a user has configured `inputrc` to map Shift-Tab to `menu-complete-backward`, a common setting in Bash (>= 4.x). Instead of special-casing upward navigation in `LineEditor#input_key`, we now allow it to be processed by the branch that calls `process_key`. The extracted method no longer includes the editing mode check since this check is already made by `#wrap_method_call` by the time `#completion_journey_up` (or `#menu_complete_backward`) is called. Since upward navigation is happening in a method other than `#input_key` now, the `completion_occurs` variable that used to be local to `#input_key` is changed to an instance variable so that the new method can change its value. (I see many examples of mutating such instance variables in `LineEditor`, so I assumed this would be an uncontroversial change consistent with the coding practices already in place.) Test coverage of this change has been added to the emacs and vi `KeyActor` tests. Many thanks to @ima1zumi for their very helpful comments on ruby#675 which encouraged me to contribute this work!
navigation (ruby/reline#677) Fixes ruby/reline#675 This commit extracts the upward navigation condition in `LineEditor#input_key` to a new private method, and adds a new alias. This change allows Reline to support upward navigation in when a user has configured `inputrc` to map Shift-Tab to `menu-complete-backward`, a common setting in Bash (>= 4.x). Instead of special-casing upward navigation in `LineEditor#input_key`, we now allow it to be processed by the branch that calls `process_key`. The extracted method no longer includes the editing mode check since this check is already made by `#wrap_method_call` by the time `#completion_journey_up` (or `#menu_complete_backward`) is called. Since upward navigation is happening in a method other than `#input_key` now, the `completion_occurs` variable that used to be local to `#input_key` is changed to an instance variable so that the new method can change its value. (I see many examples of mutating such instance variables in `LineEditor`, so I assumed this would be an uncontroversial change consistent with the coding practices already in place.) Test coverage of this change has been added to the emacs and vi `KeyActor` tests. Many thanks to @ima1zumi for their very helpful comments on #675 which encouraged me to contribute this work! ruby/reline@2ccdb374a4
navigation (ruby/reline#677) Fixes ruby/reline#675 This commit extracts the upward navigation condition in `LineEditor#input_key` to a new private method, and adds a new alias. This change allows Reline to support upward navigation in when a user has configured `inputrc` to map Shift-Tab to `menu-complete-backward`, a common setting in Bash (>= 4.x). Instead of special-casing upward navigation in `LineEditor#input_key`, we now allow it to be processed by the branch that calls `process_key`. The extracted method no longer includes the editing mode check since this check is already made by `#wrap_method_call` by the time `#completion_journey_up` (or `#menu_complete_backward`) is called. Since upward navigation is happening in a method other than `#input_key` now, the `completion_occurs` variable that used to be local to `#input_key` is changed to an instance variable so that the new method can change its value. (I see many examples of mutating such instance variables in `LineEditor`, so I assumed this would be an uncontroversial change consistent with the coding practices already in place.) Test coverage of this change has been added to the emacs and vi `KeyActor` tests. Many thanks to @ima1zumi for their very helpful comments on ruby#675 which encouraged me to contribute this work! ruby/reline@2ccdb374a4
Description
Navigating through multi-line autocomplete results in IRB using the Tab key works as expected. Using S-Tab takes the current selection instead of navigating back up. I have S-Tab configured for
menu-complete-backward
in.inputrc
(see below), and it works fine when I turn multi-line off and use readline (seeirb_info
pastes below).When I look at https://github.com/ruby/reline/blob/master/lib/reline/line_editor.rb#L1137, the value of
key.char
comes through as the symbol:menu_complete_backward
, which reline does not seem to know how to handle. If I re-map S-Tab frommenu-complete-backward
tocompletion-journey-up
, upward navigation works in IRB but breaks upward/backward navigation in other command-line tools, e.g., file completion, likely becausecompletion-journey-up
does not seem to be defined or used beyond reline (as far as I can tell!).Terminal Emulator, Shell, etc.
USE_MULTILINE=false
):The text was updated successfully, but these errors were encountered: