mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
Sort file entries by name
This commit is contained in:
@@ -128,6 +128,7 @@ impl Localhost {
|
|||||||
/// ### list_dir
|
/// ### list_dir
|
||||||
///
|
///
|
||||||
/// List files in current directory
|
/// List files in current directory
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn list_dir(&self) -> Vec<FsEntry> {
|
pub fn list_dir(&self) -> Vec<FsEntry> {
|
||||||
self.files.clone()
|
self.files.clone()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,6 +151,19 @@ impl FileExplorer {
|
|||||||
pub fn popd(&mut self) -> Option<PathBuf> {
|
pub fn popd(&mut self) -> Option<PathBuf> {
|
||||||
self.dirstack.pop_front()
|
self.dirstack.pop_front()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ### sort_files_by_name
|
||||||
|
///
|
||||||
|
/// Sort explorer files by their name
|
||||||
|
pub fn sort_files_by_name(&mut self) {
|
||||||
|
self.files.sort_by_key(|x: &FsEntry| {
|
||||||
|
match x {
|
||||||
|
FsEntry::Directory(dir) => dir.name.clone(),
|
||||||
|
FsEntry::File(file) => file.name.clone()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ## FileExplorerTab
|
/// ## FileExplorerTab
|
||||||
@@ -667,6 +680,8 @@ impl FileTransferActivity {
|
|||||||
// Reset index
|
// Reset index
|
||||||
self.local.index = 0;
|
self.local.index = 0;
|
||||||
self.local.files = files;
|
self.local.files = files;
|
||||||
|
// Sort files
|
||||||
|
self.local.sort_files_by_name();
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
self.log(
|
self.log(
|
||||||
@@ -685,7 +700,9 @@ impl FileTransferActivity {
|
|||||||
Ok(files) => {
|
Ok(files) => {
|
||||||
// Reset index
|
// Reset index
|
||||||
self.remote.index = 0;
|
self.remote.index = 0;
|
||||||
self.remote.files = files
|
self.remote.files = files;
|
||||||
|
// Sort files
|
||||||
|
self.remote.sort_files_by_name();
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
self.log(
|
self.log(
|
||||||
@@ -1469,7 +1486,8 @@ impl FileTransferActivity {
|
|||||||
LogLevel::Info,
|
LogLevel::Info,
|
||||||
format!("Created directory \"{}\"", input).as_ref(),
|
format!("Created directory \"{}\"", input).as_ref(),
|
||||||
);
|
);
|
||||||
self.local.files = self.context.as_ref().unwrap().local.list_dir();
|
let wrkdir: PathBuf = self.context.as_ref().unwrap().local.pwd();
|
||||||
|
self.local_scan(wrkdir.as_path());
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
// Report err
|
// Report err
|
||||||
|
|||||||
Reference in New Issue
Block a user