feat(bind): extend key binding support#740
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR extends the bind builtin to support binding key sequences to readline functions (not just shell commands). It introduces a distinction between shell command bindings and readline function/command bindings, adds parsing for both types, implements translations of readline functions to reedline events, and includes comprehensive test coverage.
- Adds support for parsing and binding key sequences to readline functions (e.g.,
"\C-a":beginning-of-line) - Implements translation of
InputFunctionvariants to reedline events in the interactive layer - Refactors the parser to distinguish between shell command bindings and readline target bindings
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| brush-parser/src/readline_binding.rs | Splits binding types into KeySequenceShellCommandBinding (for shell commands) and KeySequenceReadlineBinding (for readline functions/commands); adds parsing functions for both |
| brush-interactive/src/reedline/edit_mode.rs | Implements translate_input_function_to_reedline_event() to map InputFunction variants to reedline events; adds support for Repaint event |
| brush-interactive/src/interactive_shell.rs | Updates buffer handling logic to support programmatically-generated edit buffers from executed commands |
| brush-core/src/sys/unix/input.rs | Renames get_key_from_key_code() to try_get_key_from_key_code() and changes return type from Result to Option |
| brush-core/src/error.rs | Adds new error variant UnknownKeyBindingFunction for invalid function names |
| brush-builtins/src/bind.rs | Refactors to use new parser functions, adds parse_key_sequence_and_readline_target(), implements bind_key_sequence_to_readline_target(), adds escape sequence handling, includes unit tests |
Public API changes for crate: brush-coreRemoved itemsAdded itemsPublic API changes for crate: brush-parserRemoved itemsAdded itemsPerformance Benchmark Report
Code Coverage Report: Only Changed Files listed
Minimum allowed coverage is Test Summary: bash-completion test suite
|
Test Results 3 files 23 suites 7m 16s ⏱️ Results for commit 0c69c89. |
|
I've done some manual testing. This change makes things better for Two steps forward, one step back. With that said, this looks to be a general improvement so I'm going to move forward with merging it. There are still errors from readline "macros", though. |
Extends the
bindbuiltin to support binding key sequences to readline functions (previously it only supported shell commands). Bindings to more complex macros remain unimplemented."\C-a":beginning-of-line)InputFunctionvariants to reedline events in the interactive layer