yazi_core/manager/commands/
paste.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use yazi_shared::event::CmdCow;

use crate::{manager::Manager, tasks::Tasks};

struct Opt {
	force:  bool,
	follow: bool,
}

impl From<CmdCow> for Opt {
	fn from(c: CmdCow) -> Self { Self { force: c.bool("force"), follow: c.bool("follow") } }
}

impl Manager {
	#[yazi_codegen::command]
	pub fn paste(&mut self, opt: Opt, tasks: &Tasks) {
		let (src, dest) = (self.yanked.iter().collect::<Vec<_>>(), self.cwd());

		if self.yanked.cut {
			tasks.file_cut(&src, dest, opt.force);

			self.tabs.iter_mut().for_each(|t| _ = t.selected.remove_many(&src, false));
			self.unyank(());
		} else {
			tasks.file_copy(&src, dest, opt.force, opt.follow);
		}
	}
}