mirror of
https://github.com/sxyazi/yazi.git
synced 2024-12-19 14:51:42 +03:00
feat: show keywords when in search mode (#152)
This commit is contained in:
parent
e6fccf9d17
commit
4c98a351c9
@ -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);
|
||||
|
@ -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 {
|
||||
|
@ -4,6 +4,7 @@ use std::{ffi::{OsStr, OsString}, fmt::{Debug, Formatter}, ops::{Deref, DerefMut
|
||||
pub struct Url {
|
||||
scheme: UrlScheme,
|
||||
path: PathBuf,
|
||||
frag: Option<String>,
|
||||
}
|
||||
|
||||
#[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() }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user