Merge pull request #76 from christopher-l/fix/file-tree-ordering

Fix inconsistent ordering in the file tree
This commit is contained in:
daa84 2018-03-22 10:58:32 +03:00 committed by GitHub
commit ec220814b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -337,8 +337,11 @@ impl FileBrowserWidget {
fn cmp_dirs_first(lhs: &DirEntry, rhs: &DirEntry) -> io::Result<Ordering> { fn cmp_dirs_first(lhs: &DirEntry, rhs: &DirEntry) -> io::Result<Ordering> {
let lhs_metadata = fs::metadata(lhs.path())?; let lhs_metadata = fs::metadata(lhs.path())?;
let rhs_metadata = fs::metadata(rhs.path())?; let rhs_metadata = fs::metadata(rhs.path())?;
if lhs_metadata.file_type() == rhs_metadata.file_type() { if lhs_metadata.is_dir() == rhs_metadata.is_dir() {
Ok(lhs.path().cmp(&rhs.path())) Ok(lhs.path()
.to_string_lossy()
.to_lowercase()
.cmp(&rhs.path().to_string_lossy().to_lowercase()))
} else { } else {
if lhs_metadata.is_dir() { if lhs_metadata.is_dir() {
Ok(Ordering::Less) Ok(Ordering::Less)