Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: forward close params to quit #2185

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions yazi-core/src/manager/commands/close.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
use yazi_shared::event::CmdCow;

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

#[derive(Default)]
struct Opt {
no_cwd_file: bool,
}

impl From<()> for Opt {
fn from(_: ()) -> Self { Self::default() }
}

impl From<CmdCow> for Opt {
fn from(c: CmdCow) -> Self { Self { no_cwd_file: c.bool("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(quit::Opt{ no_cwd_file: opt.no_cwd_file }, tasks);
}
}
4 changes: 2 additions & 2 deletions yazi-core/src/manager/commands/quit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use yazi_shared::event::{CmdCow, EventQuit};
use crate::{manager::Manager, tasks::Tasks};

#[derive(Default)]
struct Opt {
no_cwd_file: bool,
pub struct Opt {
pub no_cwd_file: bool,
}
impl From<()> for Opt {
fn from(_: ()) -> Self { Self::default() }
Expand Down
Loading