From faebd782198cc3d92e604fad8717cd057b76cebe Mon Sep 17 00:00:00 2001 From: sxyazi Date: Tue, 2 Jan 2024 01:33:06 +0800 Subject: [PATCH] .. [no ci] --- yazi-core/src/completion/commands/arrow.rs | 20 ++++++++++++-------- yazi-core/src/completion/commands/close.rs | 6 +++--- yazi-core/src/help/commands/filter.rs | 6 +++--- yazi-core/src/manager/commands/create.rs | 3 +-- yazi-core/src/manager/commands/link.rs | 10 +++++++--- yazi-core/src/manager/commands/open.rs | 20 +++++++++----------- yazi-core/src/manager/commands/paste.rs | 6 +++--- yazi-core/src/manager/commands/remove.rs | 4 ++-- yazi-core/src/manager/commands/rename.rs | 9 +++------ yazi-core/src/manager/commands/yank.rs | 6 +++--- yazi-core/src/tab/commands/copy.rs | 5 ++--- yazi-core/src/tab/commands/escape.rs | 6 +++++- yazi-core/src/tab/commands/hidden.rs | 7 +++---- yazi-core/src/tab/commands/linemode.rs | 8 ++++---- yazi-core/src/tab/commands/search.rs | 10 +++++----- yazi-core/src/tab/commands/shell.rs | 3 +-- yazi-core/src/tasks/tasks.rs | 14 +++++--------- yazi-fm/src/executor.rs | 4 ++-- 18 files changed, 73 insertions(+), 74 deletions(-) diff --git a/yazi-core/src/completion/commands/arrow.rs b/yazi-core/src/completion/commands/arrow.rs index 9368b5dd..998af286 100644 --- a/yazi-core/src/completion/commands/arrow.rs +++ b/yazi-core/src/completion/commands/arrow.rs @@ -1,4 +1,4 @@ -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::completion::Completion; @@ -13,10 +13,10 @@ impl From<&Exec> for Opt { } impl Completion { - fn next(&mut self, step: usize) -> bool { + fn next(&mut self, step: usize) { let len = self.cands.len(); if len == 0 { - return false; + return; } let old = self.cursor; @@ -27,10 +27,10 @@ impl Completion { self.offset = len.saturating_sub(limit).min(self.offset + self.cursor - old); } - old != self.cursor + render!(old != self.cursor); } - fn prev(&mut self, step: usize) -> bool { + fn prev(&mut self, step: usize) { let old = self.cursor; self.cursor = self.cursor.saturating_sub(step); @@ -38,11 +38,15 @@ impl Completion { self.offset = self.offset.saturating_sub(old - self.cursor); } - old != self.cursor + render!(old != self.cursor); } - pub fn arrow(&mut self, opt: impl Into) -> bool { + pub fn arrow(&mut self, opt: impl Into) { let opt = opt.into() as Opt; - if opt.step > 0 { self.next(opt.step as usize) } else { self.prev(opt.step.unsigned_abs()) } + if opt.step > 0 { + self.next(opt.step as usize); + } else { + self.prev(opt.step.unsigned_abs()); + } } } diff --git a/yazi-core/src/completion/commands/close.rs b/yazi-core/src/completion/commands/close.rs index fdd6f785..b5876c82 100644 --- a/yazi-core/src/completion/commands/close.rs +++ b/yazi-core/src/completion/commands/close.rs @@ -1,4 +1,4 @@ -use yazi_shared::{emit, event::Exec, Layer}; +use yazi_shared::{emit, event::Exec, render, Layer}; use crate::{completion::Completion, input::Input}; @@ -16,7 +16,7 @@ impl Completion { emit!(Call(Exec::call("close", vec![]).vec(), Layer::Completion)); } - pub fn close(&mut self, opt: impl Into) -> bool { + pub fn close(&mut self, opt: impl Into) { let opt = opt.into() as Opt; if opt.submit { Input::_complete(self.selected(), self.ticket); @@ -24,6 +24,6 @@ impl Completion { self.caches.clear(); self.visible = false; - true + render!(); } } diff --git a/yazi-core/src/help/commands/filter.rs b/yazi-core/src/help/commands/filter.rs index 5a93c07b..f559f8c5 100644 --- a/yazi-core/src/help/commands/filter.rs +++ b/yazi-core/src/help/commands/filter.rs @@ -1,15 +1,15 @@ use yazi_config::popup::{Offset, Origin, Position}; -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::{help::Help, input::Input}; impl Help { - pub fn filter(&mut self, _: &Exec) -> bool { + pub fn filter(&mut self, _: &Exec) { let mut input = Input::default(); input.position = Position::new(Origin::BottomLeft, Offset::line()); self.in_filter = Some(input); self.filter_apply(); - true + render!(); } } diff --git a/yazi-core/src/manager/commands/create.rs b/yazi-core/src/manager/commands/create.rs index fb329ce6..7e46def5 100644 --- a/yazi-core/src/manager/commands/create.rs +++ b/yazi-core/src/manager/commands/create.rs @@ -15,7 +15,7 @@ impl From<&Exec> for Opt { } impl Manager { - pub fn create(&self, opt: impl Into) -> bool { + pub fn create(&self, opt: impl Into) { let opt = opt.into() as Opt; let cwd = self.cwd().to_owned(); tokio::spawn(async move { @@ -47,6 +47,5 @@ impl Manager { } Ok::<(), anyhow::Error>(()) }); - false } } diff --git a/yazi-core/src/manager/commands/link.rs b/yazi-core/src/manager/commands/link.rs index 2933aa6d..8046764d 100644 --- a/yazi-core/src/manager/commands/link.rs +++ b/yazi-core/src/manager/commands/link.rs @@ -14,9 +14,13 @@ impl From<&Exec> for Opt { } impl Manager { - pub fn link(&mut self, opt: impl Into, tasks: &Tasks) -> bool { - let opt = opt.into() as Opt; + pub fn link(&mut self, opt: impl Into, tasks: &Tasks) { let (cut, ref src) = self.yanked; - !cut && tasks.file_link(src, self.cwd(), opt.relative, opt.force) + if cut { + return; + } + + let opt = opt.into() as Opt; + tasks.file_link(src, self.cwd(), opt.relative, opt.force); } } diff --git a/yazi-core/src/manager/commands/open.rs b/yazi-core/src/manager/commands/open.rs index 48bf0b89..b1da416e 100644 --- a/yazi-core/src/manager/commands/open.rs +++ b/yazi-core/src/manager/commands/open.rs @@ -4,7 +4,7 @@ use tokio::fs; use tracing::error; use yazi_config::{popup::SelectCfg, ARGS, OPEN}; use yazi_plugin::isolate; -use yazi_shared::{emit, event::Exec, fs::{File, Url}, Layer, MIME_DIR}; +use yazi_shared::{emit, event::Exec, fs::{File, Url}, render, Layer, MIME_DIR}; use crate::{manager::Manager, select::Select, tasks::Tasks}; @@ -20,12 +20,12 @@ impl From<&Exec> for Opt { } impl Manager { - pub fn open(&mut self, opt: impl Into, tasks: &Tasks) -> bool { + pub fn open(&mut self, opt: impl Into, tasks: &Tasks) { let selected = self.selected(); if selected.is_empty() { - return false; + return; } else if Self::quit_with_selected(&selected) { - return false; + return; } let (mut done, mut todo) = (Vec::with_capacity(selected.len()), vec![]); @@ -53,7 +53,6 @@ impl Manager { Self::_open_do(opt.interactive, done); }); - false } #[inline] @@ -64,10 +63,10 @@ impl Manager { )); } - pub fn open_do(&mut self, opt: impl Into, tasks: &Tasks) -> bool { + pub fn open_do(&mut self, opt: impl Into, tasks: &Tasks) { let opt = opt.into() as Opt; let Some(targets) = opt.targets else { - return false; + return; }; let targets: Vec<_> = targets @@ -76,15 +75,15 @@ impl Manager { .collect(); if targets.is_empty() { - return false; + return; } else if !opt.interactive { tasks.file_open(&targets); - return false; + return; } let openers: Vec<_> = OPEN.common_openers(&targets).into_iter().cloned().collect(); if openers.is_empty() { - return false; + return; } let urls = targets.into_iter().map(|(u, _)| u).collect(); @@ -94,7 +93,6 @@ impl Manager { Tasks::_open(urls, openers[choice].clone()); } }); - false } fn quit_with_selected(selected: &[&File]) -> bool { diff --git a/yazi-core/src/manager/commands/paste.rs b/yazi-core/src/manager/commands/paste.rs index f1f11637..ac52b141 100644 --- a/yazi-core/src/manager/commands/paste.rs +++ b/yazi-core/src/manager/commands/paste.rs @@ -14,15 +14,15 @@ impl From<&Exec> for Opt { } impl Manager { - pub fn paste(&mut self, opt: impl Into, tasks: &Tasks) -> bool { + pub fn paste(&mut self, opt: impl Into, tasks: &Tasks) { let dest = self.cwd(); let (cut, ref src) = self.yanked; let opt = opt.into() as Opt; if cut { - tasks.file_cut(src, dest, opt.force) + tasks.file_cut(src, dest, opt.force); } else { - tasks.file_copy(src, dest, opt.force, opt.follow) + tasks.file_copy(src, dest, opt.force); } } } diff --git a/yazi-core/src/manager/commands/remove.rs b/yazi-core/src/manager/commands/remove.rs index 6716688a..a3896e88 100644 --- a/yazi-core/src/manager/commands/remove.rs +++ b/yazi-core/src/manager/commands/remove.rs @@ -17,9 +17,9 @@ impl From<&Exec> for Opt { } impl Manager { - pub fn remove(&mut self, opt: impl Into, tasks: &Tasks) -> bool { + pub fn remove(&mut self, opt: impl Into, tasks: &Tasks) { let opt = opt.into() as Opt; let targets = self.selected().into_iter().map(|f| f.url()).collect(); - tasks.file_remove(targets, opt.force, opt.permanently) + tasks.file_remove(targets, opt.force, opt.permanently); } } diff --git a/yazi-core/src/manager/commands/rename.rs b/yazi-core/src/manager/commands/rename.rs index 37fb527f..632e6092 100644 --- a/yazi-core/src/manager/commands/rename.rs +++ b/yazi-core/src/manager/commands/rename.rs @@ -29,13 +29,13 @@ impl Manager { Ok(Self::_hover(Some(new))) } - pub fn rename(&self, opt: impl Into) -> bool { + pub fn rename(&self, opt: impl Into) { if self.active().in_selecting() { return self.bulk_rename(); } let Some(hovered) = self.hovered().map(|h| h.url()) else { - return false; + return; }; let opt = opt.into() as Opt; @@ -60,10 +60,9 @@ impl Manager { } }; }); - false } - fn bulk_rename(&self) -> bool { + fn bulk_rename(&self) { let old: Vec<_> = self.selected().into_iter().map(|f| &f.url).collect(); let root = max_common_root(&old); @@ -104,8 +103,6 @@ impl Manager { let new: Vec<_> = fs::read_to_string(&tmp).await?.lines().map(PathBuf::from).collect(); Self::bulk_rename_do(root, old, new).await }); - - false } async fn bulk_rename_do(root: PathBuf, old: Vec, new: Vec) -> Result<()> { diff --git a/yazi-core/src/manager/commands/yank.rs b/yazi-core/src/manager/commands/yank.rs index cb07bea5..bb917e37 100644 --- a/yazi-core/src/manager/commands/yank.rs +++ b/yazi-core/src/manager/commands/yank.rs @@ -1,4 +1,4 @@ -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::manager::Manager; @@ -11,11 +11,11 @@ impl From<&Exec> for Opt { } impl Manager { - pub fn yank(&mut self, opt: impl Into) -> bool { + pub fn yank(&mut self, opt: impl Into) { let opt = opt.into() as Opt; self.yanked.0 = opt.cut; self.yanked.1 = self.selected().into_iter().map(|f| f.url()).collect(); - true + render!(); } } diff --git a/yazi-core/src/tab/commands/copy.rs b/yazi-core/src/tab/commands/copy.rs index aae06fbe..ddc327f4 100644 --- a/yazi-core/src/tab/commands/copy.rs +++ b/yazi-core/src/tab/commands/copy.rs @@ -13,7 +13,7 @@ impl<'a> From<&'a Exec> for Opt<'a> { } impl Tab { - pub fn copy<'a>(&self, opt: impl Into>) -> bool { + pub fn copy<'a>(&self, opt: impl Into>) { let opt = opt.into() as Opt; let mut s = OsString::new(); @@ -24,7 +24,7 @@ impl Tab { "dirname" => f.url.parent().map_or(OsStr::new(""), |p| p.as_os_str()), "filename" => f.name().unwrap_or(OsStr::new("")), "name_without_ext" => f.stem().unwrap_or(OsStr::new("")), - _ => return false, + _ => return, }); if it.peek().is_some() { s.push("\n"); @@ -32,6 +32,5 @@ impl Tab { } futures::executor::block_on(CLIPBOARD.set(s)); - false } } diff --git a/yazi-core/src/tab/commands/escape.rs b/yazi-core/src/tab/commands/escape.rs index 8ebe15ce..950f2b2d 100644 --- a/yazi-core/src/tab/commands/escape.rs +++ b/yazi-core/src/tab/commands/escape.rs @@ -50,7 +50,11 @@ impl Tab { } #[inline] - fn escape_search(&mut self) -> bool { self.search_stop() } + fn escape_search(&mut self) -> bool { + self.search_stop(); + // TODO: render + false + } pub fn escape(&mut self, opt: impl Into) { let opt = opt.into() as Opt; diff --git a/yazi-core/src/tab/commands/hidden.rs b/yazi-core/src/tab/commands/hidden.rs index 916e6ef1..f0e1dbc2 100644 --- a/yazi-core/src/tab/commands/hidden.rs +++ b/yazi-core/src/tab/commands/hidden.rs @@ -1,9 +1,9 @@ -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::{manager::Manager, tab::Tab}; impl Tab { - pub fn hidden(&mut self, e: &Exec) -> bool { + pub fn hidden(&mut self, e: &Exec) { self.conf.show_hidden = match e.args.first().map(|s| s.as_bytes()) { Some(b"show") => true, Some(b"hide") => false, @@ -11,8 +11,7 @@ impl Tab { }; if self.apply_files_attrs(false) { Manager::_hover(None); - return true; + render!(); } - false } } diff --git a/yazi-core/src/tab/commands/linemode.rs b/yazi-core/src/tab/commands/linemode.rs index 12a1049c..7e66fda5 100644 --- a/yazi-core/src/tab/commands/linemode.rs +++ b/yazi-core/src/tab/commands/linemode.rs @@ -1,16 +1,16 @@ -use yazi_shared::event::Exec; +use yazi_shared::{event::Exec, render}; use crate::tab::Tab; impl Tab { - pub fn linemode(&mut self, e: &Exec) -> bool { - self.conf.patch(|c| { + pub fn linemode(&mut self, e: &Exec) { + render!(self.conf.patch(|c| { let Some(mode) = e.args.first() else { return; }; if !mode.is_empty() && mode.len() <= 20 { c.linemode = mode.to_owned(); } - }) + })); } } diff --git a/yazi-core/src/tab/commands/search.rs b/yazi-core/src/tab/commands/search.rs index 59635de5..b5cd4ee1 100644 --- a/yazi-core/src/tab/commands/search.rs +++ b/yazi-core/src/tab/commands/search.rs @@ -5,7 +5,7 @@ use tokio::pin; use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt}; use yazi_config::popup::InputCfg; use yazi_plugin::external; -use yazi_shared::{event::Exec, fs::FilesOp}; +use yazi_shared::{event::Exec, fs::FilesOp, render}; use crate::{input::Input, manager::Manager, tab::Tab}; @@ -33,7 +33,7 @@ impl From<&Exec> for Opt { } impl Tab { - pub fn search(&mut self, opt: impl Into) -> bool { + pub fn search(&mut self, opt: impl Into) { let opt = opt.into() as Opt; if opt.type_ == OptType::None { return self.search_stop(); @@ -70,10 +70,11 @@ impl Tab { } Ok(()) })); - true + + render!(); } - pub(super) fn search_stop(&mut self) -> bool { + pub(super) fn search_stop(&mut self) { if let Some(handle) = self.search.take() { handle.abort(); } @@ -82,6 +83,5 @@ impl Tab { drop(mem::replace(&mut self.current, rep)); Manager::_refresh(); } - false } } diff --git a/yazi-core/src/tab/commands/shell.rs b/yazi-core/src/tab/commands/shell.rs index e6454a11..94d0aaff 100644 --- a/yazi-core/src/tab/commands/shell.rs +++ b/yazi-core/src/tab/commands/shell.rs @@ -20,7 +20,7 @@ impl<'a> From<&'a Exec> for Opt { } impl Tab { - pub fn shell(&self, opt: impl Into) -> bool { + pub fn shell(&self, opt: impl Into) { let mut opt = opt.into() as Opt; let selected: Vec<_> = self.selected().into_iter().map(|f| f.url()).collect(); @@ -42,6 +42,5 @@ impl Tab { spread: true, }); }); - false } } diff --git a/yazi-core/src/tasks/tasks.rs b/yazi-core/src/tasks/tasks.rs index 683629a5..0ca3e44f 100644 --- a/yazi-core/src/tasks/tasks.rs +++ b/yazi-core/src/tasks/tasks.rs @@ -77,7 +77,7 @@ impl Tasks { false } - pub fn file_cut(&self, src: &HashSet, dest: &Url, force: bool) -> bool { + pub fn file_cut(&self, src: &HashSet, dest: &Url, force: bool) { for u in src { let to = dest.join(u.file_name().unwrap()); if force && u == &to { @@ -86,10 +86,9 @@ impl Tasks { self.scheduler.file_cut(u.clone(), to, force); } } - false } - pub fn file_copy(&self, src: &HashSet, dest: &Url, force: bool, follow: bool) -> bool { + pub fn file_copy(&self, src: &HashSet, dest: &Url, force: bool) { for u in src { let to = dest.join(u.file_name().unwrap()); if force && u == &to { @@ -98,10 +97,9 @@ impl Tasks { self.scheduler.file_copy(u.clone(), to, force, follow); } } - false } - pub fn file_link(&self, src: &HashSet, dest: &Url, relative: bool, force: bool) -> bool { + pub fn file_link(&self, src: &HashSet, dest: &Url, relative: bool, force: bool) { for u in src { let to = dest.join(u.file_name().unwrap()); if force && *u == to { @@ -110,10 +108,9 @@ impl Tasks { self.scheduler.file_link(u.clone(), to, relative, force); } } - false } - pub fn file_remove(&self, targets: Vec, force: bool, permanently: bool) -> bool { + pub fn file_remove(&self, targets: Vec, force: bool, permanently: bool) { if force { for u in targets { if permanently { @@ -122,7 +119,7 @@ impl Tasks { self.scheduler.file_trash(u); } } - return false; + return; } let scheduler = self.scheduler.clone(); @@ -146,7 +143,6 @@ impl Tasks { } } }); - false } pub fn plugin_micro(&self, name: &str) { self.scheduler.plugin_micro(name.to_owned()); } diff --git a/yazi-fm/src/executor.rs b/yazi-fm/src/executor.rs index f0d40d52..dd1b8bce 100644 --- a/yazi-fm/src/executor.rs +++ b/yazi-fm/src/executor.rs @@ -289,7 +289,7 @@ impl<'a> Executor<'a> { match exec.cmd.as_str() { "close" => self.app.cx.help.toggle(Layer::Help), - _ => false, + _ => {} } } @@ -309,7 +309,7 @@ impl<'a> Executor<'a> { match exec.cmd.as_str() { "help" => self.app.cx.help.toggle(Layer::Completion), - _ => false, + _ => {} } } }