sort entries in directory view
This commit is contained in:
parent
aecedfb4be
commit
cbc924f46e
1 changed files with 10 additions and 0 deletions
10
src/main.rs
10
src/main.rs
|
@ -8,6 +8,7 @@ use crossterm::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{
|
||||||
|
cmp::Ordering,
|
||||||
env, fs,
|
env, fs,
|
||||||
io::{stdout, Write},
|
io::{stdout, Write},
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
|
@ -255,6 +256,15 @@ impl Navigator {
|
||||||
for file in fs::read_dir(&self.path).unwrap().flatten() {
|
for file in fs::read_dir(&self.path).unwrap().flatten() {
|
||||||
self.files.push(file.path());
|
self.files.push(file.path());
|
||||||
}
|
}
|
||||||
|
self.files[1..].sort_unstable_by(|path, other| {
|
||||||
|
if path.is_dir() == other.is_dir() {
|
||||||
|
path.cmp(other)
|
||||||
|
} else if path.is_dir() {
|
||||||
|
Ordering::Less
|
||||||
|
} else {
|
||||||
|
Ordering::Greater
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn any_unsaved(&self) -> bool {
|
fn any_unsaved(&self) -> bool {
|
||||||
|
|
Loading…
Reference in a new issue