Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion yazi-config/src/theme/filetype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl Filetype {
}

self.mime.as_ref().is_some_and(|p| p.match_mime(mime))
|| self.name.as_ref().is_some_and(|n| n.match_path(&file.url, file.is_dir()))
|| self.name.as_ref().is_some_and(|n| n.match_path(file.url(), file.is_dir()))
}
}

Expand Down
6 changes: 3 additions & 3 deletions yazi-config/src/theme/icons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ impl Icons {

#[inline]
fn match_by_glob(&self, file: &File) -> Option<&Icon> {
self.globs.iter().find(|(p, _)| p.match_path(&file.url, file.is_dir())).map(|(_, i)| i)
self.globs.iter().find(|(p, _)| p.match_path(file.url(), file.is_dir())).map(|(_, i)| i)
}

#[inline]
fn match_by_name(&self, file: &File) -> Option<&Icon> {
let name = file.name()?.to_str()?;
let name = file.name().to_str()?;
if file.is_dir() {
self.dirs.get(name).or_else(|| self.dirs.get(&name.to_ascii_lowercase()))
} else {
Expand All @@ -62,7 +62,7 @@ impl Icons {

#[inline]
fn match_by_ext(&self, file: &File) -> Option<&Icon> {
let ext = file.url.extension()?.to_str()?;
let ext = file.url().extension()?.to_str()?;
self.exts.get(ext).or_else(|| self.exts.get(&ext.to_ascii_lowercase()))
}
}
Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/manager/commands/bulk_rename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl Manager {
}

if !succeeded.is_empty() {
Pubsub::pub_from_bulk(succeeded.iter().map(|(u, f)| (u, &f.url)).collect());
Pubsub::pub_from_bulk(succeeded.iter().map(|(u, f)| (u, f.url())).collect());
FilesOp::Upserting(cwd, succeeded).emit();
}
drop(permit);
Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/manager/commands/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl Manager {
}

if let Ok(f) = File::from(new.clone()).await {
FilesOp::Upserting(parent, HashMap::from_iter([(f.url(), f)])).emit();
FilesOp::Upserting(parent, HashMap::from_iter([(f.url_owned(), f)])).emit();
TabProxy::reveal(&new)
}
Ok(())
Expand Down
6 changes: 3 additions & 3 deletions yazi-core/src/manager/commands/hover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl Manager {

// Hover on the file
render!(self.current_or_mut(opt.tab).repos(opt.url.as_ref()));
if opt.url.zip(self.current_or(opt.tab).hovered()).is_some_and(|(u, f)| u == f.url) {
if opt.url.zip(self.current_or(opt.tab).hovered()).is_some_and(|(u, f)| &u == f.url()) {
// `hover(Some)` occurs after user actions, such as create, rename, reveal, etc.
// At this point, it's intuitive to track the location of this file regardless.
self.current_or_mut(opt.tab).tracing = true;
Expand All @@ -45,12 +45,12 @@ impl Manager {
to_watch.insert(&p.cwd);
}
if let Some(h) = tab.current.hovered().filter(|&h| h.is_dir()) {
to_watch.insert(&h.url);
to_watch.insert(h.url());
}
}
self.watcher.watch(to_watch);

// Publish through DDS
Pubsub::pub_from_hover(self.active().idx, self.hovered().map(|h| &h.url));
Pubsub::pub_from_hover(self.active().idx, self.hovered().map(|h| h.url()));
}
}
6 changes: 3 additions & 3 deletions yazi-core/src/manager/commands/open.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl Manager {
if !self.active_mut().try_escape_visual() {
return;
}
let Some(hovered) = self.hovered().map(|h| h.url()) else {
let Some(hovered) = self.hovered().map(|h| h.url_owned()) else {
return;
};

Expand Down Expand Up @@ -63,7 +63,7 @@ impl Manager {
}
}

done.extend(files.iter().map(|f| (f.url(), String::new())));
done.extend(files.iter().map(|f| (f.url_owned(), String::new())));
if let Err(e) = isolate::fetch("mime", files).await {
error!("Fetch `mime` failed in opening: {e}");
}
Expand Down Expand Up @@ -111,7 +111,7 @@ impl Manager {

let find = |folder: Option<&Folder>| {
folder.is_some_and(|folder| {
folder.cwd == p && folder.files.iter().any(|f| f.is_dir() && f.url == *url)
folder.cwd == p && folder.files.iter().any(|f| f.is_dir() && url == f.url())
})
};

Expand Down
6 changes: 3 additions & 3 deletions yazi-core/src/manager/commands/peek.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ impl Manager {
};

let folder = self.active().hovered_folder().map(|f| (f.offset, f.cha));
if !self.active().preview.same_url(&hovered.url) {
if !self.active().preview.same_url(hovered.url()) {
self.active_mut().preview.skip = folder.map(|f| f.0).unwrap_or_default();
render!(self.active_mut().preview.reset());
}

let opt = opt.into() as Opt;
if matches!(opt.only_if, Some(ref u) if *u != hovered.url) {
if matches!(opt.only_if, Some(ref u) if u != hovered.url()) {
return;
}

Expand All @@ -55,7 +55,7 @@ impl Manager {
return;
}

let mime = self.mimetype.get(&hovered.url).cloned().unwrap_or_default();
let mime = self.mimetype.get(hovered.url()).cloned().unwrap_or_default();
if !mime.is_empty() {
// Wait till mimetype is resolved to avoid flickering
self.active_mut().preview.go(hovered, &mime, opt.force);
Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/manager/commands/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl Manager {
if !self.active_mut().try_escape_visual() {
return;
}
let Some(hovered) = self.hovered().map(|h| &h.url) else {
let Some(hovered) = self.hovered().map(|h| h.url()) else {
return;
};

Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/manager/commands/rename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl Manager {
if !self.active_mut().try_escape_visual() {
return;
}
let Some(hovered) = self.hovered().map(|h| h.url()) else {
let Some(hovered) = self.hovered().map(|h| h.url_owned()) else {
return;
};

Expand Down
4 changes: 2 additions & 2 deletions yazi-core/src/manager/commands/seek.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ impl Manager {

let mime = if hovered.is_dir() {
MIME_DIR
} else if let Some(s) = self.mimetype.get(&hovered.url) {
} else if let Some(s) = self.mimetype.get(hovered.url()) {
s
} else {
return render!(self.active_mut().preview.reset());
};

let Some(previewer) = PLUGIN.previewer(&hovered.url, mime) else {
let Some(previewer) = PLUGIN.previewer(hovered.url(), mime) else {
return render!(self.active_mut().preview.reset());
};

Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/manager/commands/tab_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl Tabs {
} else if let Some(h) = self.active().current.hovered() {
tab.conf = self.active().conf.clone();
tab.apply_files_attrs();
tab.reveal(h.url.to_owned());
tab.reveal(h.url_owned());
} else {
tab.conf = self.active().conf.clone();
tab.apply_files_attrs();
Expand Down
6 changes: 3 additions & 3 deletions yazi-core/src/manager/commands/update_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl Manager {
Self::update_current(tab, op, tasks);
} else if matches!(&tab.parent, Some(p) if p.cwd == *url) {
Self::update_parent(tab, op);
} else if matches!(tab.current.hovered(), Some(h) if h.url == *url) {
} else if matches!(tab.current.hovered(), Some(h) if url == h.url()) {
Self::update_hovered(tab, op);
} else {
Self::update_history(tab, op);
Expand All @@ -73,7 +73,7 @@ impl Manager {
}

fn update_current(tab: &mut Tab, op: Cow<FilesOp>, tasks: &Tasks) {
let hovered = tab.current.hovered().filter(|_| tab.current.tracing).map(|h| h.url());
let hovered = tab.current.hovered().filter(|_| tab.current.tracing).map(|h| h.url_owned());
let calc = !matches!(*op, FilesOp::Size(..) | FilesOp::Deleting(..));

let foreign = matches!(op, Cow::Borrowed(_));
Expand Down Expand Up @@ -113,7 +113,7 @@ impl Manager {
);

let folder = tab.history.entry(op.url().clone()).or_insert_with(|| Folder::from(op.url()));
let hovered = folder.hovered().filter(|_| folder.tracing).map(|h| h.url());
let hovered = folder.hovered().filter(|_| folder.tracing).map(|h| h.url_owned());
if folder.update(op.into_owned()) {
folder.repos(hovered);
}
Expand Down
4 changes: 2 additions & 2 deletions yazi-core/src/manager/commands/update_mimetype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ impl Manager {
.current()
.paginate(self.current().page)
.iter()
.filter(|&f| updates.contains_key(&f.url))
.filter(|&f| updates.contains_key(f.url()))
.cloned()
.collect();

let repeek = self.hovered().is_some_and(|f| updates.contains_key(&f.url));
let repeek = self.hovered().is_some_and(|f| updates.contains_key(f.url()));
self.mimetype.extend(updates);

if repeek {
Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/manager/yanked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl Yanked {
let (removal, addition) = match op {
FilesOp::Deleting(_, urls) => (urls.iter().collect(), vec![]),
FilesOp::Updating(_, urls) | FilesOp::Upserting(_, urls) => {
urls.iter().filter(|(u, _)| self.contains(u)).map(|(u, f)| (u, f.url())).unzip()
urls.iter().filter(|(u, _)| self.contains(u)).map(|(u, f)| (u, f.url_owned())).unzip()
}
_ => (vec![], vec![]),
};
Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/tab/commands/enter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ use crate::tab::Tab;

impl Tab {
pub fn enter(&mut self, _: Cmd) {
self.current.hovered().filter(|h| h.is_dir()).map(|h| h.url()).map(|u| self.cd(u));
self.current.hovered().filter(|h| h.is_dir()).map(|h| h.url_owned()).map(|u| self.cd(u));
}
}
2 changes: 1 addition & 1 deletion yazi-core/src/tab/commands/escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl Tab {

render!();
let urls: Vec<_> =
indices.into_iter().filter_map(|i| self.current.files.get(i)).map(|f| &f.url).collect();
indices.into_iter().filter_map(|i| self.current.files.get(i)).map(|f| f.url()).collect();

let same = !self.current.cwd.is_search();
if !select {
Expand Down
4 changes: 2 additions & 2 deletions yazi-core/src/tab/commands/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ impl Tab {
ManagerProxy::update_paged(); // Update for paged files in next loop
}

let hovered = self.current.hovered().map(|f| f.url());
let hovered = self.current.hovered().map(|f| f.url_owned());
if !self.current.files.set_filter(filter) {
return;
}

self.current.repos(hovered.as_ref());
if self.current.hovered().map(|f| &f.url) != hovered.as_ref() {
if self.current.hovered().map(|f| f.url()) != hovered.as_ref() {
ManagerProxy::hover(None, self.idx);
}

Expand Down
4 changes: 2 additions & 2 deletions yazi-core/src/tab/commands/hidden.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ impl Tab {
_ => !self.conf.show_hidden,
};

let hovered = self.current.hovered().map(|f| f.url());
let hovered = self.current.hovered().map(|f| f.url_owned());
self.apply_files_attrs();

if hovered.as_ref() != self.current.hovered().map(|f| &f.url) {
if hovered.as_ref() != self.current.hovered().map(|f| f.url()) {
ManagerProxy::hover(hovered, self.idx);
} else if self.current.hovered().is_some_and(|f| f.is_dir()) {
ManagerProxy::peek(true);
Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/tab/commands/preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl TryFrom<Cmd> for Opt {

impl Tab {
pub fn preview(&mut self, opt: impl TryInto<Opt>) {
let Some(hovered) = self.current.hovered().map(|h| &h.url) else {
let Some(hovered) = self.current.hovered().map(|h| h.url()) else {
return render!(self.preview.reset());
};

Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/tab/commands/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl<'a> From<Cmd> for Opt<'a> {
impl<'a> Tab {
pub fn select(&mut self, opt: impl Into<Opt<'a>>) {
let opt = opt.into() as Opt;
let Some(url) = opt.url.or_else(|| self.current.hovered().map(|h| Cow::Borrowed(&h.url)))
let Some(url) = opt.url.or_else(|| self.current.hovered().map(|h| Cow::Borrowed(h.url())))
else {
return;
};
Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/tab/commands/select_all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl From<Option<bool>> for Opt {

impl Tab {
pub fn select_all(&mut self, opt: impl Into<Opt>) {
let iter = self.current.files.iter().map(|f| &f.url);
let iter = self.current.files.iter().map(|f| f.url());
let (removal, addition): (Vec<_>, Vec<_>) = match opt.into().state {
Some(true) => (vec![], iter.collect()),
Some(false) => (iter.collect(), vec![]),
Expand Down
8 changes: 4 additions & 4 deletions yazi-core/src/tab/finder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl Finder {
pub(super) fn prev(&self, files: &Files, cursor: usize, include: bool) -> Option<isize> {
for i in !include as usize..files.len() {
let idx = (cursor + files.len() - i) % files.len();
if files[idx].name().is_some_and(|n| self.filter.matches(n)) {
if self.filter.matches(files[idx].name()) {
return Some(idx as isize - cursor as isize);
}
}
Expand All @@ -28,7 +28,7 @@ impl Finder {
pub(super) fn next(&self, files: &Files, cursor: usize, include: bool) -> Option<isize> {
for i in !include as usize..files.len() {
let idx = (cursor + i) % files.len();
if files[idx].name().is_some_and(|n| self.filter.matches(n)) {
if self.filter.matches(files[idx].name()) {
return Some(idx as isize - cursor as isize);
}
}
Expand All @@ -43,11 +43,11 @@ impl Finder {

let mut i = 0u8;
for file in files.iter() {
if file.name().map(|n| self.filter.matches(n)) != Some(true) {
if !self.filter.matches(file.name()) {
continue;
}

self.matched.insert(file.url(), i);
self.matched.insert(file.url_owned(), i);
if self.matched.len() > 99 {
break;
}
Expand Down
6 changes: 3 additions & 3 deletions yazi-core/src/tab/preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ pub struct Preview {

impl Preview {
pub fn go(&mut self, file: File, mime: &str, force: bool) {
if !force && self.content_unchanged(&file.url, file.cha) {
if !force && self.content_unchanged(file.url(), file.cha) {
return;
}

let Some(previewer) = PLUGIN.previewer(&file.url, mime) else {
let Some(previewer) = PLUGIN.previewer(file.url(), mime) else {
self.reset();
return;
};
Expand All @@ -38,7 +38,7 @@ impl Preview {
}

pub fn go_folder(&mut self, file: File, dir: Option<Cha>, force: bool) {
let (cha, url) = (file.cha, file.url());
let (cha, url) = (file.cha, file.url_owned());
self.go(file, MIME_DIR, force);

if self.content_unchanged(&url, cha) {
Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/tab/selected.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl Selected {
let (removal, addition) = match op {
FilesOp::Deleting(_, urls) => (urls.iter().collect(), vec![]),
FilesOp::Updating(_, urls) | FilesOp::Upserting(_, urls) => {
urls.iter().filter(|&(u, _)| self.contains_key(u)).map(|(u, f)| (u, &f.url)).unzip()
urls.iter().filter(|&(u, _)| self.contains_key(u)).map(|(u, f)| (u, f.url())).unzip()
}
_ => (vec![], vec![]),
};
Expand Down
Loading