diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d364a3..88d0830 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Not showing `.` and `..` when `--tree` with `--all` from [zwpaper](https://github.com/zwpaper) [#477](https://github.com/Peltoche/lsd/issues/477) ### Fixed - Fix handling blocks passed without -l in cli from [meain](https://github.com/meain) +- Fixed sorting of . and .. when used with folder from [meain](https://github.com/meain) ## [0.19.0] - 2020-12-13 ### Added diff --git a/src/meta/mod.rs b/src/meta/mod.rs index d29fcee..83d3112 100644 --- a/src/meta/mod.rs +++ b/src/meta/mod.rs @@ -87,8 +87,9 @@ impl Meta { current_meta = self.clone(); current_meta.name.name = ".".to_owned(); - let parent_meta = + let mut parent_meta = Self::from_path(&self.path.join(Component::ParentDir), flags.dereference.0)?; + parent_meta.name.name = "..".to_owned(); content.push(current_meta); content.push(parent_meta); diff --git a/tests/integration.rs b/tests/integration.rs index 8d34eb6..b65ff03 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -97,6 +97,21 @@ fn test_list_all_populated_directory() { .stdout(predicate::str::is_match("\\.\n\\.\\.\none\ntwo\n$").unwrap()); } +#[test] +fn test_almost_sort_with_folder() { + let tmp = tempdir(); + tmp.child("z").create_dir_all().unwrap(); + tmp.child("z/a").touch().unwrap(); + + cmd() + .current_dir(tmp.path()) + .arg("-a") + .arg("--ignore-config") + .arg("z") + .assert() + .stdout(predicate::str::is_match("\\.\n\\.\\.\na\n$").unwrap()); +} + #[test] fn test_list_inode_populated_directory() { let dir = tempdir();