From adfb86d699210f6dabc0be603eb24f123d1368ec Mon Sep 17 00:00:00 2001 From: Adam Schmalhofer Date: Wed, 17 Jul 2024 20:41:04 +0200 Subject: [PATCH] Fix cc anc c$ in vi-mode in vim the deleted text can be pasted, while previously that didn't happen in reedline --- src/edit_mode/vi/command.rs | 6 +++--- src/edit_mode/vi/parser.rs | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/edit_mode/vi/command.rs b/src/edit_mode/vi/command.rs index e7bf0426..9c4f0711 100644 --- a/src/edit_mode/vi/command.rs +++ b/src/edit_mode/vi/command.rs @@ -212,10 +212,10 @@ impl Command { }, Self::Change => { let op = match motion { - Motion::End => Some(vec![ReedlineOption::Edit(EditCommand::ClearToLineEnd)]), + Motion::End => Some(vec![ReedlineOption::Edit(EditCommand::CutToLineEnd)]), Motion::Line => Some(vec![ - ReedlineOption::Edit(EditCommand::MoveToStart { select: false }), - ReedlineOption::Edit(EditCommand::ClearToLineEnd), + ReedlineOption::Edit(EditCommand::MoveToLineStart { select: false }), + ReedlineOption::Edit(EditCommand::CutToLineEnd), ]), Motion::NextWord => Some(vec![ReedlineOption::Edit(EditCommand::CutWordRight)]), Motion::NextBigWord => { diff --git a/src/edit_mode/vi/parser.rs b/src/edit_mode/vi/parser.rs index 81d0e396..5d554ce8 100644 --- a/src/edit_mode/vi/parser.rs +++ b/src/edit_mode/vi/parser.rs @@ -511,8 +511,7 @@ mod tests { #[case(&['d', 'b'], ReedlineEvent::Multiple(vec![ReedlineEvent::Edit(vec![EditCommand::CutWordLeft])]))] #[case(&['d', 'B'], ReedlineEvent::Multiple(vec![ReedlineEvent::Edit(vec![EditCommand::CutBigWordLeft])]))] #[case(&['c', 'c'], ReedlineEvent::Multiple(vec![ - //ReedlineEvent::Edit(vec![EditCommand::CutCurrentLine]), ReedlineEvent::Repaint]))] - ReedlineEvent::Edit(vec![EditCommand::MoveToStart{select: false}]), ReedlineEvent::Edit(vec![EditCommand::ClearToLineEnd]), ReedlineEvent::Repaint]))] + ReedlineEvent::Edit(vec![EditCommand::MoveToLineStart { select: false }]), ReedlineEvent::Edit(vec![EditCommand::CutToLineEnd]), ReedlineEvent::Repaint]))] #[case(&['c', 'w'], ReedlineEvent::Multiple(vec![ReedlineEvent::Edit(vec![EditCommand::CutWordRight]), ReedlineEvent::Repaint]))] #[case(&['c', 'W'], ReedlineEvent::Multiple(vec![ReedlineEvent::Edit(vec![EditCommand::CutBigWordRight]), ReedlineEvent::Repaint]))] #[case(&['c', 'e'], ReedlineEvent::Multiple(vec![ReedlineEvent::Edit(vec![EditCommand::CutWordRight]), ReedlineEvent::Repaint]))]