fix: incorrect $0 and $@ parameters in shell command under empty directories

This commit is contained in:
sxyazi 2025-10-03 16:45:11 +08:00
parent 4d39194cd8
commit 27170ce70b
No known key found for this signature in database
3 changed files with 11 additions and 3 deletions

View file

@ -1,5 +1,3 @@
use std::iter;
use anyhow::Result;
use ratatui::layout::Rect;
use tokio::task::JoinHandle;
@ -96,7 +94,9 @@ impl Tab {
}
pub fn hovered_and_selected(&self) -> Box<dyn Iterator<Item = &UrlBuf> + '_> {
let Some(h) = self.hovered() else { return Box::new(iter::empty()) };
let Some(h) = self.hovered() else {
return Box::new([UrlBuf::new()].into_iter().chain(self.selected.values()));
};
if self.selected.is_empty() {
Box::new([&h.url, &h.url].into_iter())
} else {

View file

@ -84,6 +84,8 @@ impl LocBuf {
Ok(Self { inner: loc.inner, uri, urn })
}
pub const fn empty() -> Self { Self { inner: PathBuf::new(), uri: 0, urn: 0 } }
pub fn zeroed(path: impl Into<PathBuf>) -> Self {
let loc = Self::from(path.into());
let Loc { inner, uri, urn } = Loc::zeroed(&loc.inner);

View file

@ -79,6 +79,12 @@ impl PartialEq<Url<'_>> for &UrlBuf {
}
impl UrlBuf {
#[inline]
pub const fn new() -> &'static Self {
static U: UrlBuf = UrlBuf { loc: LocBuf::empty(), scheme: Scheme::Regular };
&U
}
#[inline]
pub fn join(&self, path: impl AsRef<Path>) -> Self { self.as_url().join(path) }