yazi/yazi-actor/src/mgr/tab_swap.rs
SpiritCroc b1ee2e72ff
feat: H/M/L Vim-like motion for moving cursor relative to viewport (#3970)
Co-authored-by: sxyazi <sxyazi@gmail.com>
2026-06-24 17:42:20 +08:00

30 lines
589 B
Rust

use anyhow::Result;
use yazi_dds::Pubsub;
use yazi_macro::{err, render, succ};
use yazi_parser::ArrowForm;
use yazi_shared::data::Data;
use crate::{Actor, Ctx};
pub struct TabSwap;
impl Actor for TabSwap {
type Form = ArrowForm;
const NAME: &str = "tab_swap";
fn act(cx: &mut Ctx, form: Self::Form) -> Result<Data> {
let tabs = cx.tabs_mut();
let new = form.step.add(tabs.cursor, tabs.len(), 0, 0, 0);
if new == tabs.cursor {
succ!();
}
tabs.items.swap(tabs.cursor, new);
tabs.cursor = new;
err!(Pubsub::pub_after_tab(cx.active().id));
succ!(render!());
}
}