Handle more events for until keybindings
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 817
- Forks
- 247
- Avg merge
- 4d 14h
- Merged PRs (30d)
- 30
Description
Currently, until keybindings only work for menu events: all other events will be considered successful and hence the remaining until cases will not be considered.
I can think of a number of events that should be considered to have failed at times: e.g. MoveToLineStart if the cursor is already at line start, CutSelection if nothing is selected, BackspaceWord if there is nothing to remove etc.
However, the only event I am personally interested in is CopySelection and CopySelectionSystem (which should reasonably fail if no text is currently selected), since being able to use until for those events would allow for e.g.
event: {
until : [
{ edit: copyselectionsystem }
{ send: CtrlC }
]
}
which in theory should emulate the behavior that many terminal emulators support as an option: Ctrl+c copies text if any text is selected, otherwise it interrupts / clears the line.
Sidenote
The line editor unselects the selected text when copyselectionsystem is activated, which seems a bit odd as I am not aware of any other text editor where that is the case.
References
The nu documentation mentions that
At the moment of this writing, only the Menu events allow this type of layering. The other non menu event types will always return a success value, meaning that the
untilevent will stop as soon as it reaches the command.
For the ctrl+c behavior, e.g. the Kitty terminal has the mappable action copy_or_interrupt, which the line editor expectedly does not respect since it always receives Ctrl+c from Kitty, as Kitty does not recognize the readline text as selected.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the handling of until keybindings and the CopySelection and CopySelectionSystem events in the line editor. Check how menu events report failure, then define and verify failure behavior for copying with no selection; the work is done when the remaining until cases can respond to event failure without breaking existing menu behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100