Skip to content

Refactor edit commands and create readline for vi mode #1885

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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

BlueDrink9
Copy link
Contributor

@BlueDrink9 BlueDrink9 commented May 26, 2025

Generally speaking the refactor allows you to override how edit actions are applied, which I uses to make sure that the modifier/selection applies by creating a vim motion instead of trying to select terminal text. The refactors to the edit commands are fairly minimal, it's just converting the functions into user actions and refactoring out actions to access the internal dictionaries.

In draft mode while I dog food it for a week or so to ensure it is ready, But reviews are welcome anyway

@BlueDrink9
Copy link
Contributor Author

I haven't noticed any issues with this while dogfooding it for the last two weeks, including both inside and outside of terminal, so it looks like I haven't broken the regular commands either.

@BlueDrink9 BlueDrink9 marked this pull request as ready for review June 6, 2025 23:10
"""
action_type = action.type

if action_type in simple_action_callbacks:
Copy link
Collaborator

@AndreasArvidsson AndreasArvidsson Jun 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if statements means that you can't add more callbacks to a context implementation of get_simple_action_callback().
get_simple_action_callback() could return None to indicate that there is no simple action call back for this action type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good catch, I have altered it. I don't think there is any way to call the original mod action function once you have created a context override, correct? So while your modification would let someone entirely replace the callbacks, it would not let them extend it. Any ideas for how to do this? It will actually have an immediate benefit, because I will be able to map ctrl+w to clear word left, which will be faster and cleaner than the current implementation of having to press escape

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can call actions.next() to call that next most specific implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants