mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat: add ripgrep-all support for search
This commit is contained in:
parent
52a5ab59e9
commit
8b2d89cbaf
3 changed files with 8 additions and 2 deletions
|
|
@ -48,8 +48,9 @@ impl Tab {
|
|||
let hidden = self.pref.show_hidden;
|
||||
|
||||
self.search = Some(tokio::spawn(async move {
|
||||
let rx = if opt.via == SearchOptVia::Rg {
|
||||
let rx = if opt.via == SearchOptVia::Rg || opt.via == SearchOptVia::Rga {
|
||||
external::rg(external::RgOpt {
|
||||
rga: SearchOptVia::Rga == opt.via,
|
||||
cwd: cwd.clone(),
|
||||
hidden,
|
||||
subject: opt.subject.into_owned(),
|
||||
|
|
|
|||
4
yazi-plugin/src/external/rg.rs
vendored
4
yazi-plugin/src/external/rg.rs
vendored
|
|
@ -7,13 +7,15 @@ use yazi_shared::url::Url;
|
|||
|
||||
pub struct RgOpt {
|
||||
pub cwd: Url,
|
||||
pub rga: bool,
|
||||
pub hidden: bool,
|
||||
pub subject: String,
|
||||
pub args: Vec<String>,
|
||||
}
|
||||
|
||||
pub fn rg(opt: RgOpt) -> Result<UnboundedReceiver<File>> {
|
||||
let mut child = Command::new("rg")
|
||||
let commandname = if opt.rga { "rga" } else { "rg" };
|
||||
let mut child = Command::new(commandname)
|
||||
.args(["--color=never", "--files-with-matches", "--smart-case"])
|
||||
.arg(if opt.hidden { "--hidden" } else { "--no-hidden" })
|
||||
.args(opt.args)
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ impl TryFrom<CmdCow> for SearchOpt {
|
|||
pub enum SearchOptVia {
|
||||
// TODO: remove `None` in the future
|
||||
None,
|
||||
Rga,
|
||||
Rg,
|
||||
Fd,
|
||||
}
|
||||
|
|
@ -44,6 +45,7 @@ impl From<&str> for SearchOptVia {
|
|||
match value {
|
||||
"rg" => Self::Rg,
|
||||
"fd" => Self::Fd,
|
||||
"rga" => Self::Rga,
|
||||
_ => Self::None,
|
||||
}
|
||||
}
|
||||
|
|
@ -53,6 +55,7 @@ impl Display for SearchOptVia {
|
|||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.write_str(match self {
|
||||
Self::Rg => "rg",
|
||||
Self::Rga => "rga",
|
||||
Self::Fd => "fd",
|
||||
Self::None => "none",
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue