mirror of
https://github.com/lsd-rs/lsd
synced 2025-01-06 00:48:46 +00:00
show contents for symlink folders(fix #345)
This commit is contained in:
parent
87d1520763
commit
cffda506f1
3 changed files with 24 additions and 2 deletions
|
@ -66,7 +66,10 @@ fn inner_display_grid(
|
||||||
// print the files first.
|
// print the files first.
|
||||||
for meta in metas {
|
for meta in metas {
|
||||||
// Maybe skip showing the directory meta now; show its contents later.
|
// Maybe skip showing the directory meta now; show its contents later.
|
||||||
if let (true, FileType::Directory { .. }) = (skip_dirs, meta.file_type) {
|
if skip_dirs
|
||||||
|
&& (matches!(meta.file_type, FileType::Directory{..})
|
||||||
|
|| matches!(meta.file_type, FileType::SymLink { is_dir: true }))
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,7 +224,10 @@ fn should_display_folder_path(depth: usize, metas: &[Meta]) -> bool {
|
||||||
} else {
|
} else {
|
||||||
let folder_number = metas
|
let folder_number = metas
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|x| matches!(x.file_type, FileType::Directory { .. }))
|
.filter(|x| {
|
||||||
|
matches!(x.file_type, FileType::Directory { .. })
|
||||||
|
|| matches!(x.file_type, FileType::SymLink { is_dir: true })
|
||||||
|
})
|
||||||
.count();
|
.count();
|
||||||
|
|
||||||
folder_number > 1 || folder_number < metas.len()
|
folder_number > 1 || folder_number < metas.len()
|
||||||
|
|
|
@ -63,6 +63,7 @@ impl Meta {
|
||||||
|
|
||||||
match self.file_type {
|
match self.file_type {
|
||||||
FileType::Directory { .. } => (),
|
FileType::Directory { .. } => (),
|
||||||
|
FileType::SymLink { is_dir: true } => (),
|
||||||
_ => return Ok(None),
|
_ => return Ok(None),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -204,6 +204,21 @@ fn test_dereference_link_right_type_and_no_link() {
|
||||||
.stdout(predicate::str::contains(link_icon).not());
|
.stdout(predicate::str::contains(link_icon).not());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[test]
|
||||||
|
fn test_show_folder_content_of_symlink() {
|
||||||
|
let dir = tempdir();
|
||||||
|
dir.child("target").child("inside").touch().unwrap();
|
||||||
|
let link = dir.path().join("link");
|
||||||
|
fs::symlink("target", &link).unwrap();
|
||||||
|
|
||||||
|
cmd()
|
||||||
|
.arg(link)
|
||||||
|
.assert()
|
||||||
|
.stdout(predicate::str::starts_with("link").not())
|
||||||
|
.stdout(predicate::str::starts_with("inside"));
|
||||||
|
}
|
||||||
|
|
||||||
fn cmd() -> Command {
|
fn cmd() -> Command {
|
||||||
Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap()
|
Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue