fix: pass through show_hidden when building default Files (#2057)

This commit is contained in:
三咲雅 · Misaki Masa 2024-12-16 20:57:20 +08:00 committed by GitHub
parent f4eef99f7e
commit c96b1d3aa1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 2 deletions

View file

@ -6,7 +6,6 @@ use yazi_fs::{Cha, File, Files, FilesOp, FolderStage, Step};
use yazi_proxy::ManagerProxy;
use yazi_shared::{Id, url::{Url, Urn}};
#[derive(Default)]
pub struct Folder {
pub url: Url,
pub cha: Cha,
@ -20,6 +19,21 @@ pub struct Folder {
pub tracing: bool,
}
impl Default for Folder {
fn default() -> Self {
Self {
url: Default::default(),
cha: Default::default(),
files: Files::new(MANAGER.show_hidden),
stage: Default::default(),
offset: Default::default(),
cursor: Default::default(),
page: Default::default(),
tracing: Default::default(),
}
}
}
impl From<&Url> for Folder {
fn from(url: &Url) -> Self { Self { url: url.clone(), ..Default::default() } }
}

View file

@ -28,6 +28,8 @@ impl Deref for Files {
}
impl Files {
pub fn new(show_hidden: bool) -> Self { Self { show_hidden, ..Default::default() } }
pub async fn from_dir(dir: &Url) -> std::io::Result<UnboundedReceiver<File>> {
let mut it = fs::read_dir(dir).await?;
let (tx, rx) = mpsc::unbounded_channel();

View file

@ -68,7 +68,6 @@ local function setup(_, opts)
function()
ya.manager_emit("shell", {
orphan = true,
confirm = true,
"zoxide add " .. ya.quote(tostring(cx.active.current.cwd)),
})
end