feat: add ripgrep-all support for search

This commit is contained in:
paperbenni 2025-02-22 17:21:43 +01:00
parent 52a5ab59e9
commit 8b2d89cbaf
3 changed files with 8 additions and 2 deletions

View file

@ -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(),

View file

@ -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)

View file

@ -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",
})