reverted spacing changes

This commit is contained in:
AidanV 2024-04-20 11:23:09 -07:00
parent b32847afba
commit e749c455bf
2 changed files with 15 additions and 63 deletions

View file

@ -2,27 +2,21 @@ use std::ops::Deref;
use mlua::{AnyUserData, IntoLua, Lua, UserDataFields, UserDataMethods}; use mlua::{AnyUserData, IntoLua, Lua, UserDataFields, UserDataMethods};
use yazi_config::THEME; use yazi_config::THEME;
use yazi_plugin::{ use yazi_plugin::{bindings::{Cast, Cha, Icon, Range}, elements::Style, url::Url};
bindings::{Cast, Cha, Icon, Range},
elements::Style,
url::Url,
};
use yazi_shared::MIME_DIR; use yazi_shared::MIME_DIR;
use super::{CtxRef, SCOPE}; use super::{CtxRef, SCOPE};
pub(super) struct File { pub(super) struct File {
idx: usize, idx: usize,
folder: *const yazi_core::folder::Folder, folder: *const yazi_core::folder::Folder,
tab: *const yazi_core::tab::Tab, tab: *const yazi_core::tab::Tab,
} }
impl Deref for File { impl Deref for File {
type Target = yazi_shared::fs::File; type Target = yazi_shared::fs::File;
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target { &self.folder().files[self.idx] }
&self.folder().files[self.idx]
}
} }
impl File { impl File {
@ -137,12 +131,8 @@ impl File {
} }
#[inline] #[inline]
fn folder(&self) -> &yazi_core::folder::Folder { fn folder(&self) -> &yazi_core::folder::Folder { unsafe { &*self.folder } }
unsafe { &*self.folder }
}
#[inline] #[inline]
fn tab(&self) -> &yazi_core::tab::Tab { fn tab(&self) -> &yazi_core::tab::Tab { unsafe { &*self.tab } }
unsafe { &*self.tab }
}
} }

View file

@ -1,16 +1,8 @@
use std::{ use std::{collections::VecDeque, fs::Metadata, path::{Path, PathBuf}};
collections::VecDeque,
fs::Metadata,
path::{Path, PathBuf},
};
use anyhow::Result; use anyhow::Result;
use filetime::{set_file_mtime, FileTime}; use filetime::{set_file_mtime, FileTime};
use tokio::{ use tokio::{fs, io, select, sync::{mpsc, oneshot}, time};
fs, io, select,
sync::{mpsc, oneshot},
time,
};
pub async fn accessible(path: &Path) -> bool { pub async fn accessible(path: &Path) -> bool {
match fs::symlink_metadata(path).await { match fs::symlink_metadata(path).await {
@ -111,10 +103,7 @@ pub fn copy_with_progress(
#[cfg(unix)] #[cfg(unix)]
#[allow(clippy::collapsible_else_if)] #[allow(clippy::collapsible_else_if)]
pub fn permissions(m: libc::mode_t) -> String { pub fn permissions(m: libc::mode_t) -> String {
use libc::{ use libc::{S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO, S_IFLNK, S_IFMT, S_IFSOCK, S_IRGRP, S_IROTH, S_IRUSR, S_ISGID, S_ISUID, S_ISVTX, S_IWGRP, S_IWOTH, S_IWUSR, S_IXGRP, S_IXOTH, S_IXUSR};
S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO, S_IFLNK, S_IFMT, S_IFSOCK, S_IRGRP, S_IROTH, S_IRUSR,
S_ISGID, S_ISUID, S_ISVTX, S_IWGRP, S_IWOTH, S_IWUSR, S_IXGRP, S_IXOTH, S_IXUSR,
};
let mut s = String::with_capacity(10); let mut s = String::with_capacity(10);
// File type // File type
@ -132,51 +121,27 @@ pub fn permissions(m: libc::mode_t) -> String {
s.push(if m & S_IRUSR != 0 { 'r' } else { '-' }); s.push(if m & S_IRUSR != 0 { 'r' } else { '-' });
s.push(if m & S_IWUSR != 0 { 'w' } else { '-' }); s.push(if m & S_IWUSR != 0 { 'w' } else { '-' });
s.push(if m & S_IXUSR != 0 { s.push(if m & S_IXUSR != 0 {
if m & S_ISUID != 0 { if m & S_ISUID != 0 { 's' } else { 'x' }
's'
} else {
'x'
}
} else { } else {
if m & S_ISUID != 0 { if m & S_ISUID != 0 { 'S' } else { '-' }
'S'
} else {
'-'
}
}); });
// Group // Group
s.push(if m & S_IRGRP != 0 { 'r' } else { '-' }); s.push(if m & S_IRGRP != 0 { 'r' } else { '-' });
s.push(if m & S_IWGRP != 0 { 'w' } else { '-' }); s.push(if m & S_IWGRP != 0 { 'w' } else { '-' });
s.push(if m & S_IXGRP != 0 { s.push(if m & S_IXGRP != 0 {
if m & S_ISGID != 0 { if m & S_ISGID != 0 { 's' } else { 'x' }
's'
} else {
'x'
}
} else { } else {
if m & S_ISGID != 0 { if m & S_ISGID != 0 { 'S' } else { '-' }
'S'
} else {
'-'
}
}); });
// Other // Other
s.push(if m & S_IROTH != 0 { 'r' } else { '-' }); s.push(if m & S_IROTH != 0 { 'r' } else { '-' });
s.push(if m & S_IWOTH != 0 { 'w' } else { '-' }); s.push(if m & S_IWOTH != 0 { 'w' } else { '-' });
s.push(if m & S_IXOTH != 0 { s.push(if m & S_IXOTH != 0 {
if m & S_ISVTX != 0 { if m & S_ISVTX != 0 { 't' } else { 'x' }
't'
} else {
'x'
}
} else { } else {
if m & S_ISVTX != 0 { if m & S_ISVTX != 0 { 'T' } else { '-' }
'T'
} else {
'-'
}
}); });
s s
@ -193,9 +158,6 @@ pub fn owner(uid: u32, gid: u32) -> String {
None => String::default(), None => String::default(),
}; };
format!("{username} {groupname}") format!("{username} {groupname}")
//users::get_user_by_uid(uid).unwrap().name().to_str().unwrap_or_default().to_string()
//+ " "
//+ users::get_group_by_gid(gid).unwrap().name().to_str().unwrap_or_default()
} }
// Find the max common root in a list of files // Find the max common root in a list of files