mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
27 lines
559 B
Rust
27 lines
559 B
Rust
use yazi_config::keymap::{Exec, KeymapLayer};
|
|
|
|
use crate::{completion::Completion, emit};
|
|
|
|
pub struct Opt {
|
|
submit: bool,
|
|
}
|
|
|
|
impl From<&Exec> for Opt {
|
|
fn from(e: &Exec) -> Self { Self { submit: e.named.contains_key("submit") } }
|
|
}
|
|
|
|
impl Completion {
|
|
pub fn close(&mut self, opt: impl Into<Opt>) -> bool {
|
|
let opt = opt.into() as Opt;
|
|
if opt.submit {
|
|
emit!(Call(
|
|
Exec::call("complete", vec![self.selected().into()]).with("ticket", self.ticket).vec(),
|
|
KeymapLayer::Input
|
|
));
|
|
}
|
|
|
|
self.caches.clear();
|
|
self.visible = false;
|
|
true
|
|
}
|
|
}
|