mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 23:01:05 +00:00
feat: new --no-cwd-file option for the close command (#2185)
Co-authored-by: sxyazi <sxyazi@gmail.com>
This commit is contained in:
parent
b495f78dfe
commit
856f37b5b3
2 changed files with 17 additions and 8 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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") } }
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue