diff --git a/app/src/header/layout.rs b/app/src/header/layout.rs index 15695166..4371b95f 100644 --- a/app/src/header/layout.rs +++ b/app/src/header/layout.rs @@ -19,11 +19,11 @@ impl<'a> Widget for Layout<'a> { .constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref()) .split(area); - let current = &self.cx.manager.current(); - let location = if current.cwd.is_search() { - format!("{} (search)", readable_path(¤t.cwd)) + let cwd = &self.cx.manager.current().cwd; + let location = if cwd.is_search() { + format!("{} (search: {})", readable_path(cwd), cwd.frag().unwrap()) } else { - readable_path(¤t.cwd) + readable_path(cwd) }; Paragraph::new(location).style(Style::new().fg(Color::Cyan)).render(chunks[0], buf); diff --git a/core/src/manager/tab.rs b/core/src/manager/tab.rs index 6e8b656a..b24fb4b2 100644 --- a/core/src/manager/tab.rs +++ b/core/src/manager/tab.rs @@ -289,7 +289,7 @@ impl Tab { handle.abort(); } - let cwd = self.current.cwd.to_search(); + let mut cwd = self.current.cwd.clone(); let hidden = self.show_hidden; self.search = Some(tokio::spawn(async move { @@ -297,6 +297,7 @@ impl Tab { bail!("canceled") }; + cwd = cwd.into_search(subject.clone()); let rx = if grep { external::rg(external::RgOpt { cwd: cwd.clone(), hidden, subject }) } else { diff --git a/shared/src/url.rs b/shared/src/url.rs index 9b5b340c..10e45db3 100644 --- a/shared/src/url.rs +++ b/shared/src/url.rs @@ -4,6 +4,7 @@ use std::{ffi::{OsStr, OsString}, fmt::{Debug, Formatter}, ops::{Deref, DerefMut pub struct Url { scheme: UrlScheme, path: PathBuf, + frag: Option, } #[derive(Clone, Copy, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -114,11 +115,12 @@ impl Url { pub fn is_search(&self) -> bool { self.scheme == UrlScheme::Search } #[inline] - pub fn to_search(&self) -> Self { self.clone().into_search() } + pub fn to_search(&self, frag: String) -> Self { self.clone().into_search(frag) } #[inline] - pub fn into_search(mut self) -> Self { + pub fn into_search(mut self, frag: String) -> Self { self.scheme = UrlScheme::Search; + self.frag = Some(frag); self } @@ -137,4 +139,8 @@ impl Url { // --- Path #[inline] pub fn set_path(&mut self, path: PathBuf) { self.path = path; } + + // --- Frag + #[inline] + pub fn frag(&self) -> Option<&str> { self.frag.as_deref() } }