mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Make ticket optional for cmp:trigger
This commit is contained in:
parent
452b435b71
commit
2fd94ab4c7
2 changed files with 12 additions and 6 deletions
|
|
@ -12,18 +12,24 @@ use crate::cmp::Cmp;
|
|||
impl Cmp {
|
||||
#[yazi_codegen::command]
|
||||
pub fn trigger(&mut self, opt: TriggerOpt) {
|
||||
if opt.ticket < self.ticket {
|
||||
if let Some(ticket) = opt.ticket {
|
||||
if ticket < self.ticket {
|
||||
return;
|
||||
} else {
|
||||
self.ticket = ticket;
|
||||
}
|
||||
}
|
||||
|
||||
self.ticket = opt.ticket;
|
||||
let Some((parent, word)) = Self::split_path(&opt.word) else {
|
||||
return self.close(false);
|
||||
};
|
||||
|
||||
if self.caches.contains_key(&parent) {
|
||||
return self.show(
|
||||
Cmd::default().with_any("cache-name", parent).with("word", word).with("ticket", opt.ticket),
|
||||
Cmd::default()
|
||||
.with_any("cache-name", parent)
|
||||
.with("word", word)
|
||||
.with("ticket", self.ticket),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@ use yazi_shared::{Id, SStr, event::{CmdCow, Data}};
|
|||
|
||||
pub struct TriggerOpt {
|
||||
pub word: SStr,
|
||||
pub ticket: Id,
|
||||
pub ticket: Option<Id>,
|
||||
}
|
||||
|
||||
impl From<CmdCow> for TriggerOpt {
|
||||
fn from(mut c: CmdCow) -> Self {
|
||||
Self {
|
||||
word: c.take_first_str().unwrap_or_default(),
|
||||
ticket: c.get("ticket").and_then(Data::as_id).unwrap_or_default(),
|
||||
ticket: c.get("ticket").and_then(Data::as_id),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue