Skip to content

Commit

Permalink
feat: new --no-cwd-file option for the close command (#2185)
Browse files Browse the repository at this point in the history
Co-authored-by: sxyazi <[email protected]>
  • Loading branch information
igxlin and sxyazi authored Jan 11, 2025
1 parent b495f78 commit 856f37b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
18 changes: 15 additions & 3 deletions yazi-core/src/manager/commands/close.rs
Original file line number Diff line number Diff line change
@@ -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);
}
}
7 changes: 2 additions & 5 deletions yazi-core/src/manager/commands/quit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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") } }
Expand Down

0 comments on commit 856f37b

Please sign in to comment.