Skip to content
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

Handle more events for until keybindings #876

Open
LemmusLemmus opened this issue Jan 26, 2025 · 0 comments
Open

Handle more events for until keybindings #876

LemmusLemmus opened this issue Jan 26, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@LemmusLemmus
Copy link

LemmusLemmus commented Jan 26, 2025

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 until event 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.

@LemmusLemmus LemmusLemmus added the enhancement New feature or request label Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant