feat: new --no-cwd-file option for the close command (#2185)

Co-authored-by: sxyazi <sxyazi@gmail.com>
This commit is contained in:
gx 2025-01-11 09:59:53 +08:00 committed by GitHub
parent b495f78dfe
commit 856f37b5b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 8 deletions

View file

@ -1,12 +1,24 @@
use yazi_shared::event::CmdCow;
use crate::{manager::Manager, tasks::Tasks};
use crate::{manager::{Manager, commands::quit}, tasks::Tasks};
#[derive(Default)]
struct Opt {
no_cwd_file: bool,
}
impl From<CmdCow> for Opt {
fn from(c: CmdCow) -> Self { Self { no_cwd_file: c.bool("no-cwd-file") } }
}
impl From<Opt> for quit::Opt {
fn from(value: Opt) -> Self { Self { no_cwd_file: value.no_cwd_file } }
}
impl Manager {
pub fn close(&mut self, _: CmdCow, tasks: &Tasks) {
#[yazi_codegen::command]
pub fn close(&mut self, opt: Opt, tasks: &Tasks) {
if self.tabs.len() > 1 {
return self.tabs.close(self.tabs.cursor);
}
self.quit((), tasks);
self.quit(opt, tasks);
}
}

View file

@ -9,11 +9,8 @@ use yazi_shared::event::{CmdCow, EventQuit};
use crate::{manager::Manager, tasks::Tasks};
#[derive(Default)]
struct Opt {
no_cwd_file: bool,
}
impl From<()> for Opt {
fn from(_: ()) -> Self { Self::default() }
pub(super) struct Opt {
pub(super) no_cwd_file: bool,
}
impl From<CmdCow> for Opt {
fn from(c: CmdCow) -> Self { Self { no_cwd_file: c.bool("no-cwd-file") } }