mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
Files found from search are now displayed with their relative path from working directory
This commit is contained in:
committed by
Christian Visintin
parent
3927fb2a39
commit
bc6b7b582e
@@ -29,12 +29,12 @@ Released on FIXME:
|
|||||||
> ❄️ Winter update 2022 ⛄
|
> ❄️ Winter update 2022 ⛄
|
||||||
|
|
||||||
- **Enhancements**:
|
- **Enhancements**:
|
||||||
- Find feature:
|
- **Find** feature:
|
||||||
- A "wait popup" will now be displayed while searching files
|
- A "wait popup" will now be displayed while searching files
|
||||||
- If find command doesn't return any result show an info dialog and not an empty explorer
|
- If find command doesn't return any result show an info dialog and not an empty explorer
|
||||||
- It is now possible to keep navigating on the other explorer while "found tab" is open
|
- It is now possible to keep navigating on the other explorer while "found tab" is open
|
||||||
- ❗ It is not possible though to have the "found tab" on both explorers (otherwise you wouldn't be able to tell whether you're transferring files)
|
- ❗ It is not possible though to have the "found tab" on both explorers (otherwise you wouldn't be able to tell whether you're transferring files)
|
||||||
- Files found from search are now displayed with their absolute path
|
- Files found from search are now displayed with their relative path from working directory
|
||||||
|
|
||||||
## 0.7.0
|
## 0.7.0
|
||||||
|
|
||||||
|
|||||||
@@ -28,9 +28,11 @@
|
|||||||
// Locals
|
// Locals
|
||||||
use super::FsEntry;
|
use super::FsEntry;
|
||||||
use crate::utils::fmt::{fmt_path_elide, fmt_pex, fmt_time};
|
use crate::utils::fmt::{fmt_path_elide, fmt_pex, fmt_time};
|
||||||
|
use crate::utils::path::diff_paths;
|
||||||
// Ext
|
// Ext
|
||||||
use bytesize::ByteSize;
|
use bytesize::ByteSize;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
use std::path::PathBuf;
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
use users::{get_group_by_gid, get_user_by_uid};
|
use users::{get_group_by_gid, get_user_by_uid};
|
||||||
// Types
|
// Types
|
||||||
@@ -346,15 +348,23 @@ impl Formatter {
|
|||||||
cur_str: &str,
|
cur_str: &str,
|
||||||
prefix: &str,
|
prefix: &str,
|
||||||
fmt_len: Option<&usize>,
|
fmt_len: Option<&usize>,
|
||||||
_fmt_extra: Option<&String>,
|
fmt_extra: Option<&String>,
|
||||||
) -> String {
|
) -> String {
|
||||||
|
let p = match fmt_extra {
|
||||||
|
None => fsentry.get_abs_path(),
|
||||||
|
Some(rel) => diff_paths(
|
||||||
|
fsentry.get_abs_path().as_path(),
|
||||||
|
PathBuf::from(rel.as_str()).as_path(),
|
||||||
|
)
|
||||||
|
.unwrap_or_else(|| fsentry.get_abs_path()),
|
||||||
|
};
|
||||||
format!(
|
format!(
|
||||||
"{}{}{}",
|
"{}{}{}",
|
||||||
cur_str,
|
cur_str,
|
||||||
prefix,
|
prefix,
|
||||||
match fmt_len {
|
match fmt_len {
|
||||||
None => fsentry.get_abs_path().display().to_string(),
|
None => p.display().to_string(),
|
||||||
Some(len) => fmt_path_elide(fsentry.get_abs_path().as_path(), *len),
|
Some(len) => fmt_path_elide(p.as_path(), *len),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -935,6 +945,8 @@ mod tests {
|
|||||||
formatter.fmt(&entry).as_str(),
|
formatter.fmt(&entry).as_str(),
|
||||||
"File path: /tmp/…/c/bar.txt"
|
"File path: /tmp/…/c/bar.txt"
|
||||||
);
|
);
|
||||||
|
let formatter: Formatter = Formatter::new("File path: {PATH:128:/tmp/a/b}");
|
||||||
|
assert_eq!(formatter.fmt(&entry).as_str(), "File path: c/bar.txt");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ### dummy_fmt
|
/// ### dummy_fmt
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ use crate::fs::explorer::{builder::FileExplorerBuilder, FileExplorer, FileSortin
|
|||||||
use crate::fs::FsEntry;
|
use crate::fs::FsEntry;
|
||||||
use crate::system::config_client::ConfigClient;
|
use crate::system::config_client::ConfigClient;
|
||||||
|
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
/// ## FileExplorerTab
|
/// ## FileExplorerTab
|
||||||
///
|
///
|
||||||
/// File explorer tab
|
/// File explorer tab
|
||||||
@@ -98,8 +100,8 @@ impl Browser {
|
|||||||
self.found.as_mut().map(|x| &mut x.1)
|
self.found.as_mut().map(|x| &mut x.1)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_found(&mut self, tab: FoundExplorerTab, files: Vec<FsEntry>) {
|
pub fn set_found(&mut self, tab: FoundExplorerTab, files: Vec<FsEntry>, wrkdir: &Path) {
|
||||||
let mut explorer = Self::build_found_explorer();
|
let mut explorer = Self::build_found_explorer(wrkdir);
|
||||||
explorer.set_files(files);
|
explorer.set_files(files);
|
||||||
self.found = Some((tab, explorer));
|
self.found = Some((tab, explorer));
|
||||||
}
|
}
|
||||||
@@ -168,13 +170,15 @@ impl Browser {
|
|||||||
/// ### build_found_explorer
|
/// ### build_found_explorer
|
||||||
///
|
///
|
||||||
/// Build explorer reading from `ConfigClient`, for found result (has some differences)
|
/// Build explorer reading from `ConfigClient`, for found result (has some differences)
|
||||||
fn build_found_explorer() -> FileExplorer {
|
fn build_found_explorer(wrkdir: &Path) -> FileExplorer {
|
||||||
FileExplorerBuilder::new()
|
FileExplorerBuilder::new()
|
||||||
.with_file_sorting(FileSorting::Name)
|
.with_file_sorting(FileSorting::Name)
|
||||||
.with_group_dirs(Some(GroupDirs::First))
|
.with_group_dirs(Some(GroupDirs::First))
|
||||||
.with_hidden_files(true)
|
.with_hidden_files(true)
|
||||||
.with_stack_size(0)
|
.with_stack_size(0)
|
||||||
.with_formatter(Some("{PATH:36} {SYMLINK}"))
|
.with_formatter(Some(
|
||||||
|
format!("{{PATH:36:{}}} {{SYMLINK}}", wrkdir.display()).as_str(),
|
||||||
|
))
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -494,6 +494,11 @@ impl Update for FileTransferActivity {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
Ok(files) => {
|
Ok(files) => {
|
||||||
|
// Get wrkdir
|
||||||
|
let wrkdir = match self.browser.tab() {
|
||||||
|
FileExplorerTab::Local => self.local().wrkdir.clone(),
|
||||||
|
_ => self.remote().wrkdir.clone(),
|
||||||
|
};
|
||||||
// Create explorer and load files
|
// Create explorer and load files
|
||||||
self.browser.set_found(
|
self.browser.set_found(
|
||||||
match self.browser.tab() {
|
match self.browser.tab() {
|
||||||
@@ -501,6 +506,7 @@ impl Update for FileTransferActivity {
|
|||||||
_ => FoundExplorerTab::Remote,
|
_ => FoundExplorerTab::Remote,
|
||||||
},
|
},
|
||||||
files,
|
files,
|
||||||
|
wrkdir.as_path(),
|
||||||
);
|
);
|
||||||
// Mount result widget
|
// Mount result widget
|
||||||
self.mount_find(input);
|
self.mount_find(input);
|
||||||
|
|||||||
Reference in New Issue
Block a user