From 48bd62f9bcb5654a80619d62529dd1fa8dc0768a Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Tue, 1 May 2012 15:58:09 +0400 Subject: [PATCH] Ticket #2783: when right panel is active, panel paths are swapped at each mc start. How to reproduce. 1. Goto ~. Run mc. Enable autosave panels setup before exit. Save options. 2. Open ~ dir in the left panel, / in the right one. Make right panel active. 3. Close mc. 4. With mc-wrapper, following is performed: 4.1. Run mc. Now ~ in the right panel, / in the left one. 4.2. Close mc. 4.3. Run mc. Now ~ in the left panel again, / in the right one. 4.4. ...and so on. 5. Without mc-wrapper, following is performed: 5.1. Run mc. Now ~ in both panels. Expected behavior with current_is_left=false 1. if mc start as mc dir dir2, dir1 is opened in the left panel, dir2 in the right one. 2. if mc starts as mc (without dir1 and dir2), active (right) panel contains working directory, other (left) one contains other_dir from panel.ini. 3. if mc start as mc dir1, dir1 is opened in the left panel, right panel contains working directory. Signed-off-by: Andrew Borodin --- src/filemanager/midnight.c | 23 +++++++++++++++++++++-- src/setup.c | 3 +-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/filemanager/midnight.c b/src/filemanager/midnight.c index dd9c902ee..cc717c241 100644 --- a/src/filemanager/midnight.c +++ b/src/filemanager/midnight.c @@ -579,7 +579,10 @@ create_panels (void) other_index = 1; current_mode = startup_left_mode; other_mode = startup_right_mode; + /* if mc_run_param0 is NULL, working directory will be used for the left panel */ current_dir = mc_run_param0; + /* mc_run_param1 is never NULL. It is setup from command line or from panels.ini + * (value of other_dir). mc_run_param1 will be used for the right panel */ other_dir = mc_run_param1; } else @@ -589,8 +592,21 @@ create_panels (void) other_index = 0; current_mode = startup_right_mode; other_mode = startup_left_mode; - current_dir = mc_run_param1; - other_dir = mc_run_param0; + + /* if mc_run_param0 is not NULL (it was setup from command line), it will be used + * for the left panel, working directory will be used for the right one; + * if mc_run_param0 is NULL, working directory will be used for the right (active) panel, + * mc_run_param1 will be used for the left one */ + if (mc_run_param0 != NULL) + { + current_dir = NULL; + other_dir = mc_run_param0; + } + else + { + current_dir = NULL; + other_dir = mc_run_param1; + } } /* 1. Get current dir */ @@ -609,7 +625,10 @@ create_panels (void) /* 3. Create active panel */ if (current_dir == NULL) + { + current_dir = vfs_path_to_str (original_dir); mc_chdir (original_dir); + } else { vfs_path_t *vpath; diff --git a/src/setup.c b/src/setup.c index 791a2bc84..2b6c9bf74 100644 --- a/src/setup.c +++ b/src/setup.c @@ -799,8 +799,7 @@ save_panel_types (void) } if (current_panel != NULL) - mc_config_set_string (mc_panels_config, "Dirs", "current_is_left", - get_current_index () == 0 ? "1" : "0"); + mc_config_set_bool (mc_panels_config, "Dirs", "current_is_left", get_current_index () == 0); if (mc_panels_config->ini_path == NULL) mc_panels_config->ini_path = g_strdup (panels_profile_name);