mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
fix: incorrect $0 and $@ parameters in shell command under empty directories (#3225)
This commit is contained in:
parent
4d39194cd8
commit
d8b0425a10
3 changed files with 18 additions and 4 deletions
|
|
@ -1,5 +1,3 @@
|
||||||
use std::iter;
|
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use ratatui::layout::Rect;
|
use ratatui::layout::Rect;
|
||||||
use tokio::task::JoinHandle;
|
use tokio::task::JoinHandle;
|
||||||
|
|
@ -96,7 +94,9 @@ impl Tab {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn hovered_and_selected(&self) -> Box<dyn Iterator<Item = &UrlBuf> + '_> {
|
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() {
|
if self.selected.is_empty() {
|
||||||
Box::new([&h.url, &h.url].into_iter())
|
Box::new([&h.url, &h.url].into_iter())
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,10 @@ impl LocBuf {
|
||||||
Ok(Self { inner: loc.inner, uri, urn })
|
Ok(Self { inner: loc.inner, uri, urn })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: use `LocBuf::empty()` when Rust 1.91.0 released
|
||||||
|
// pub const fn empty() -> Self { Self { inner: PathBuf::new(), uri: 0, urn: 0 }
|
||||||
|
// }
|
||||||
|
|
||||||
pub fn zeroed(path: impl Into<PathBuf>) -> Self {
|
pub fn zeroed(path: impl Into<PathBuf>) -> Self {
|
||||||
let loc = Self::from(path.into());
|
let loc = Self::from(path.into());
|
||||||
let Loc { inner, uri, urn } = Loc::zeroed(&loc.inner);
|
let Loc { inner, uri, urn } = Loc::zeroed(&loc.inner);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{borrow::Cow, ffi::OsStr, fmt::{Debug, Formatter}, hash::BuildHasher, path::{Path, PathBuf}, str::FromStr};
|
use std::{borrow::Cow, ffi::OsStr, fmt::{Debug, Formatter}, hash::BuildHasher, path::{Path, PathBuf}, str::FromStr, sync::OnceLock};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
@ -79,6 +79,16 @@ impl PartialEq<Url<'_>> for &UrlBuf {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UrlBuf {
|
impl UrlBuf {
|
||||||
|
#[inline]
|
||||||
|
pub fn new() -> &'static Self {
|
||||||
|
static U: OnceLock<UrlBuf> = OnceLock::new();
|
||||||
|
U.get_or_init(Self::default)
|
||||||
|
|
||||||
|
// FIXME: use `LocBuf::empty()` when Rust 1.91.0 released
|
||||||
|
// static U: UrlBuf = UrlBuf { loc: LocBuf::empty(), scheme: Scheme::Regular
|
||||||
|
// }; &U
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn join(&self, path: impl AsRef<Path>) -> Self { self.as_url().join(path) }
|
pub fn join(&self, path: impl AsRef<Path>) -> Self { self.as_url().join(path) }
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue