aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/lf/lf-make-map/src/mapping/map_key.rs
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/by-name/lf/lf-make-map/src/mapping/map_key.rs')
-rw-r--r--pkgs/by-name/lf/lf-make-map/src/mapping/map_key.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/pkgs/by-name/lf/lf-make-map/src/mapping/map_key.rs b/pkgs/by-name/lf/lf-make-map/src/mapping/map_key.rs
index 5fd046fb..d90eb963 100644
--- a/pkgs/by-name/lf/lf-make-map/src/mapping/map_key.rs
+++ b/pkgs/by-name/lf/lf-make-map/src/mapping/map_key.rs
@@ -87,7 +87,6 @@ impl MapKey {
generated_chars.extend(
(0..(new_resolution - self.part_path.len()))
- .into_iter()
.map(|_| self.part_path.chars().last().expect("This will exists")),
);
@@ -110,14 +109,14 @@ impl MapKey {
}
pub fn display(values: &[Self]) -> String {
- values.iter().map(|value| value.key.clone()).collect()
+ values.iter().map(|value| value.key).collect()
}
fn part_path_to_key(part: &str, number_of_chars: usize) -> String {
fn make(pat: char, part: &str, number_of_chars: usize) -> String {
let mut acc = String::new();
- if !part.split(pat).all(|part| part.len() > 0) {
+ if !part.split(pat).all(|part| !part.is_empty()) {
panic!(
"\
Can't turn this path '{}' to a mapping.
@@ -152,6 +151,13 @@ This should not happen, please report the bug!",
make('_', part, number_of_chars)
} else if part.contains('-') && !part.starts_with('-') && !part.ends_with('-') {
make('-', part, number_of_chars)
+ } else if part.starts_with('.') {
+ // HACK: Special case for directories like ~/.config ~/.local and so on.
+ // We just drop the starting '.' and it's easier to type. <2026-06-02>
+ part.chars()
+ .skip(1)
+ .take(number_of_chars)
+ .collect::<String>()
} else {
part.chars().take(number_of_chars).collect::<String>()
};