@@ -1,7 +1,7 @@
1use helix_core::{
1use helix_core::{
3 regex::Regex,
3 regex::Regex,
4− selection,
4+ register, selection,
5 state::{Direction, Granularity, Mode, State},
5 state::{Direction, Granularity, Mode, State},
6 ChangeSet, Range, Selection, Tendril, Transaction,
6 ChangeSet, Range, Selection, Tendril, Transaction,
@@ -443,3 +443,36 @@ pub fn undo(view: &mut View, _count: usize) {
443pub fn redo(view: &mut View, _count: usize) {
443pub fn redo(view: &mut View, _count: usize) {
444 view.history.redo(&mut view.state);
444 view.history.redo(&mut view.state);
449+pub fn yank(view: &mut View, _count: usize) {
450+ // TODO: should selections be made end inclusive?
454+ .fragments(&view.state.doc().slice(..))
455+ .map(|cow| cow.into_owned())
458+ register::set('"', values);
461+pub fn paste(view: &mut View, _count: usize) {
462+ if let Some(values) = register::get('"') {
463+ let repeat = std::iter::repeat(
466+ .map(|value| Tendril::from_slice(value))
470+ let mut values = values.into_iter().map(Tendril::from).chain(repeat);
472+ let transaction = Transaction::change_by_selection(&view.state, |range| {
473+ (range.head + 1, range.head + 1, Some(values.next().unwrap()))
476+ transaction.apply(&mut view.state);