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

Fix vi mode change not pastable #807

Merged
merged 5 commits into from
Aug 5, 2024

Conversation

adaschma
Copy link
Contributor

While extending the tests for vi mode, I noticed that c$ (replace text until end of line with newly entered text) and cc (replace the entire line with newly entered text) don't actually cut the removed text. This fixed that. Verified with vim 9.1 that it should be cut a.k.a. pastable.

Test:

setup:

  1. $ cargo run --example demo -- --vi
  2. enter a text (optionally use + to enter multiple line)
  3. press to enter vi normal mode and use the arrow keys to navigate somewhere in the line

actual test:

both "cc p" and "c$ p" should now leave the text unchanged by cutting out text and pasting it back again (, but moving the cursor to the end).

#[case(&['d', 'l'], ReedlineEvent::Multiple(vec![ReedlineEvent::Edit(vec![EditCommand::Delete])]))]
#[case(&['2', 'd', 'd'], ReedlineEvent::Multiple(vec![ReedlineEvent::Edit(vec![EditCommand::CutCurrentLine]), ReedlineEvent::Edit(vec![EditCommand::CutCurrentLine])]))]
// #[case(&['d', 'j'], ReedlineEvent::Multiple(vec![ReedlineEvent::Edit(vec![EditCommand::CutCurrentLine]), ReedlineEvent::Edit(vec![EditCommand::CutCurrentLine])]))]
// #[case(&['d', 'k'], ReedlineEvent::Multiple(vec![ReedlineEvent::Up, ReedlineEvent::Edit(vec![EditCommand::CutCurrentLine]), ReedlineEvent::Edit(vec![EditCommand::CutCurrentLine])]))]
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the point of these commented out cases? Do they not work? Are they not supposed to work? Are we coming back to them later? etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They don't work. I would rather wait on adding them because (1) using this combination in vim is uncommon [citation needed] and (2) multi line edits in nushell is not very frequent, (3) there might be strange edge cases with the menu and (4) adding it will add onto the hacks and (5) we should cleanup before that as well as (6) other lower hanging fruit in the vi mode.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok, thanks for the info. i'm good with this PR. ping me when you're ready to land. hopefully no other vim users have problems with it but "you snooze, you lose".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's ready to land.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok, we typically freeze PR merges when we're this close to a release (tuesday). so, we'll probably have to wait on this one.

@fdncred fdncred merged commit 919292e into nushell:main Aug 5, 2024
6 checks passed
@fdncred
Copy link
Collaborator

fdncred commented Aug 5, 2024

Thanks

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