aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/lib.rs
diff options
context:
space:
mode:
authorPascal Kuthe2023-02-02 17:14:02 +0000
committerGitHub2023-02-02 17:14:02 +0000
commit6ed2348078a331bc2039a313bd7ad9f0bb1a00c2 (patch)
tree5382d34d59def4d84a2e3455f4cbd4b1f66ff961 /helix-term/src/lib.rs
parent62d046fa219b927c536bf6726fcae1e825346e0e (diff)
Hide duplicate symlinks from the picker (#5658)
* hide duplicate symlinks from the picker * Apply suggestions from code review Co-authored-by: g-re-g <123515925+g-re-g@users.noreply.github.com> * minor stylistic fix Co-authored-by: Michael Davis <mcarsondavis@gmail.com> --------- Co-authored-by: g-re-g <123515925+g-re-g@users.noreply.github.com> Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
Diffstat (limited to 'helix-term/src/lib.rs')
-rw-r--r--helix-term/src/lib.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/helix-term/src/lib.rs b/helix-term/src/lib.rs
index a945b20d..f0bc9129 100644
--- a/helix-term/src/lib.rs
+++ b/helix-term/src/lib.rs
@@ -10,6 +10,9 @@ pub mod health;
pub mod job;
pub mod keymap;
pub mod ui;
+use std::path::Path;
+
+use ignore::DirEntry;
pub use keymap::macros::*;
#[cfg(not(windows))]
@@ -22,3 +25,25 @@ fn true_color() -> bool {
fn true_color() -> bool {
true
}
+
+/// Function used for filtering dir entries in the various file pickers.
+fn filter_picker_entry(entry: &DirEntry, root: &Path, dedup_symlinks: bool) -> bool {
+ // We always want to ignore the .git directory, otherwise if
+ // `ignore` is turned off, we end up with a lot of noise
+ // in our picker.
+ if entry.file_name() == ".git" {
+ return false;
+ }
+
+ // We also ignore symlinks that point inside the current directory
+ // if `dedup_links` is enabled.
+ if dedup_symlinks && entry.path_is_symlink() {
+ return entry
+ .path()
+ .canonicalize()
+ .ok()
+ .map_or(false, |path| !path.starts_with(&root));
+ }
+
+ true
+}