find, panelize, internal edit, bug



Hi,

the try_to_select function in screen.c does not behave as expected in the following situation:

1. "find files" in a directory with subdirectories
2. "panelize"
3. select a file from a subdirectory that is also present in
   the main directory. Press <F4>. Press <F10>.
4. mc now selects the file from the main directory instead of
   keeping the selection on the file that has just been edited.

The appended patch fixes it. I have no idea why the code needs to strip the subdirectory and the suffix, but it basically comes from revision 1.1, so it is undocumented. :(

Roland
Index: screen.c
===================================================================
RCS file: /cvsroot/mc/mc/src/screen.c,v
retrieving revision 1.219
diff -u -p -r1.219 screen.c
--- screen.c	11 Nov 2005 03:32:40 -0000	1.219
+++ screen.c	3 Feb 2006 14:16:32 -0000
@@ -873,22 +873,16 @@ static inline void
 do_try_to_select (WPanel *panel, const char *name)
 {
     int i;
-    char *subdir;
 
     if (!name) {
         do_select(panel, 0);
 	return;
     }
 
-    /* We only want the last component of the directory,
-     * and from this only the name without suffix. */
-    subdir = vfs_strip_suffix_from_filename (x_basename(name));
-
     /* Search that subdirectory, if found select it */
     for (i = 0; i < panel->count; i++){
-	if (strcmp (subdir, panel->dir.list [i].fname) == 0) {
+	if (strcmp (name, panel->dir.list[i].fname) == 0) {
 	    do_select (panel, i);
-            g_free (subdir);
 	    return;
         }
     }
@@ -896,7 +890,6 @@ do_try_to_select (WPanel *panel, const c
     /* Try to select a file near the file that is missing */
     if (panel->selected >= panel->count)
         do_select (panel, panel->count-1);
-    g_free (subdir);
 }
 
 void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]