From 7fc3587a0dbc3d5d08ae496af7fae8ed58d21360 Mon Sep 17 00:00:00 2001 From: raj kumar <79806602+raj921@users.noreply.github.com> Date: Tue, 15 Oct 2024 22:04:27 +0530 Subject: [PATCH] Change naming convention for folders to append index after the name ### Summary This pull request modifies the `unique_name` function in the `path.rs` file to change the naming convention for folders. Instead of inserting an index before the last dot in the folder name, the index is now appended at the end of the folder name. This change aims to improve the clarity and usability of folder names when duplicates are created. ### Changes Made - Updated the logic in the `unique_name` function to check if the path is a directory. - For directories, the index is now appended at the end of the name (e.g., `a.b.c` becomes `a.b.c_1`). - Maintained the existing behavior for file names. ### Testing - The changes have been tested to ensure that both file and folder naming conventions work as expected. --- yazi-shared/src/fs/path.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/yazi-shared/src/fs/path.rs b/yazi-shared/src/fs/path.rs index dd8343e0..e6b02b41 100644 --- a/yazi-shared/src/fs/path.rs +++ b/yazi-shared/src/fs/path.rs @@ -101,14 +101,13 @@ pub async fn unique_name(mut u: Url) -> io::Result { let mut name = OsString::with_capacity(stem.len() + ext.len() + 5); name.push(&stem); - // Check if it's a directory + if p.is_dir() { - // For directories, append the index at the end + name.push("_"); name.push(i.to_string()); name.push(&ext); - } else { - // For files, keep the existing behavior + } else name.push("_"); name.push(i.to_string()); name.push(&ext);