mirror of
https://github.com/lsd-rs/lsd
synced 2024-12-15 06:22:47 +00:00
Fix sorting with almost-all flag and a folder
With a folder structure (a folder `z` with a file `a`), if we do `lsd -a` it used to be: . a .. instead of . .. a This was caused to the the parent meta having full path and us using z/.. to sort .. entry. This should now be fixed with manually changing the name to a .. .
This commit is contained in:
parent
0ca699ee2f
commit
24e6335e0a
3 changed files with 18 additions and 1 deletions
|
@ -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)
|
- Not showing `.` and `..` when `--tree` with `--all` from [zwpaper](https://github.com/zwpaper) [#477](https://github.com/Peltoche/lsd/issues/477)
|
||||||
### Fixed
|
### Fixed
|
||||||
- Fix handling blocks passed without -l in cli from [meain](https://github.com/meain)
|
- 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
|
## [0.19.0] - 2020-12-13
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -87,8 +87,9 @@ impl Meta {
|
||||||
current_meta = self.clone();
|
current_meta = self.clone();
|
||||||
current_meta.name.name = ".".to_owned();
|
current_meta.name.name = ".".to_owned();
|
||||||
|
|
||||||
let parent_meta =
|
let mut parent_meta =
|
||||||
Self::from_path(&self.path.join(Component::ParentDir), flags.dereference.0)?;
|
Self::from_path(&self.path.join(Component::ParentDir), flags.dereference.0)?;
|
||||||
|
parent_meta.name.name = "..".to_owned();
|
||||||
|
|
||||||
content.push(current_meta);
|
content.push(current_meta);
|
||||||
content.push(parent_meta);
|
content.push(parent_meta);
|
||||||
|
|
|
@ -97,6 +97,21 @@ fn test_list_all_populated_directory() {
|
||||||
.stdout(predicate::str::is_match("\\.\n\\.\\.\none\ntwo\n$").unwrap());
|
.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]
|
#[test]
|
||||||
fn test_list_inode_populated_directory() {
|
fn test_list_inode_populated_directory() {
|
||||||
let dir = tempdir();
|
let dir = tempdir();
|
||||||
|
|
Loading…
Reference in a new issue