Ticket #2529: mc-git20110403-rename-into-same-directory.diff

File mc-git20110403-rename-into-same-directory.diff, 1.5 KB (added by vitalif, 8 years ago)

Take filename as copy/move destination if same directory is opened on other panel

  • src/filemanager/file.c

    Patch for mc git version (4.8.0, 2011-04-03):
    Changes default copy/move destination to source entry name
    instead of target directory name when operating on single entry.
    It allows to rename files conveniently.
    
    diff --git a/src/filemanager/file.c b/src/filemanager/file.c
    index d74c79e..6ebbf3f 100644
    a b panel_operate (void *source_panel, FileOperation operation, gboolean force_singl 
    23492349    if (operation != OP_DELETE) 
    23502350    { 
    23512351        char *dest_dir; 
    2352         char *dest_dir_; 
     2352        char *dest_dir_ = NULL; 
    23532353        char *format; 
    23542354 
    23552355        /* Forced single operations default to the original name */ 
    2356         if (force_single) 
     2356        if (force_single || single_entry && !strcmp(panel->cwd, other_panel->cwd)) 
     2357        { 
    23572358            dest_dir = source; 
     2359            dest_dir_ = source; /* hack... */ 
     2360        } 
    23582361        else if (get_other_type () == view_listing) 
    23592362            dest_dir = other_panel->cwd; 
    23602363        else 
    panel_operate (void *source_panel, FileOperation operation, gboolean force_singl 
    23642367         * It saves user from occasional file renames (when destination 
    23652368         * dir is deleted) 
    23662369         */ 
    2367         if (!force_single && dest_dir[0] != '\0' && dest_dir[strlen (dest_dir) - 1] != PATH_SEP) 
     2370        if (!dest_dir_ && !force_single && dest_dir[0] != '\0' && dest_dir[strlen (dest_dir) - 1] != PATH_SEP) 
    23682371        { 
    23692372            /* add trailing separator */ 
    23702373            dest_dir_ = g_strconcat (dest_dir, PATH_SEP_STR, (char *) NULL);