mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-01 00:54:24 +03:00
Clarify panel->currrent if file panel is empty.
* (panel_do_cd_int): set panel->current to -1 file list is empty. * (panel_set_current_by_name): likewise. * (panel_sized_with_dir_new): likewise. * (panel_reload): likewise. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
1ac839d20c
commit
f147c8b3e2
@ -2158,6 +2158,21 @@ panel_select_ext_cmd (WPanel *panel)
|
|||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
static void
|
||||||
|
panel_set_current (WPanel *panel, int i)
|
||||||
|
{
|
||||||
|
if (i != panel->current)
|
||||||
|
{
|
||||||
|
panel->dirty = TRUE;
|
||||||
|
panel->current = i;
|
||||||
|
panel->top = panel->current - (WIDGET (panel)->rect.lines - 2) / 2;
|
||||||
|
if (panel->top < 0)
|
||||||
|
panel->top = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
panel_current_at_half (const WPanel *panel)
|
panel_current_at_half (const WPanel *panel)
|
||||||
{
|
{
|
||||||
@ -3471,6 +3486,9 @@ panel_do_cd_int (WPanel *panel, const vfs_path_t *new_dir_vpath, enum cd_enum cd
|
|||||||
&panel->sort_info, &panel->filter))
|
&panel->sort_info, &panel->filter))
|
||||||
message (D_ERROR, MSG_ERROR, _("Cannot read directory contents"));
|
message (D_ERROR, MSG_ERROR, _("Cannot read directory contents"));
|
||||||
|
|
||||||
|
if (panel->dir.len == 0)
|
||||||
|
panel_set_current (panel, -1);
|
||||||
|
|
||||||
panel_set_current_by_name (panel, get_parent_dir_name (panel->cwd_vpath, olddir_vpath));
|
panel_set_current_by_name (panel, get_parent_dir_name (panel->cwd_vpath, olddir_vpath));
|
||||||
|
|
||||||
load_hint (FALSE);
|
load_hint (FALSE);
|
||||||
@ -4272,21 +4290,6 @@ update_one_panel (int which, panel_update_flags_t flags, const char *current_fil
|
|||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void
|
|
||||||
panel_set_current (WPanel *panel, int i)
|
|
||||||
{
|
|
||||||
if (i != panel->current)
|
|
||||||
{
|
|
||||||
panel->dirty = TRUE;
|
|
||||||
panel->current = i;
|
|
||||||
panel->top = panel->current - (WIDGET (panel)->rect.lines - 2) / 2;
|
|
||||||
if (panel->top < 0)
|
|
||||||
panel->top = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/* event callback */
|
/* event callback */
|
||||||
static gboolean
|
static gboolean
|
||||||
event_update_panels (const gchar *event_group_name, const gchar *event_name,
|
event_update_panels (const gchar *event_group_name, const gchar *event_name,
|
||||||
@ -4444,6 +4447,12 @@ panel_set_current_by_name (WPanel *panel, const char *name)
|
|||||||
int i;
|
int i;
|
||||||
char *subdir;
|
char *subdir;
|
||||||
|
|
||||||
|
if (panel->dir.len == 0)
|
||||||
|
{
|
||||||
|
panel_set_current (panel, -1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
{
|
{
|
||||||
panel_set_current (panel, 0);
|
panel_set_current (panel, 0);
|
||||||
@ -4675,6 +4684,9 @@ panel_sized_with_dir_new (const char *panel_name, const WRect *r, const vfs_path
|
|||||||
&panel->sort_info, &panel->filter))
|
&panel->sort_info, &panel->filter))
|
||||||
message (D_ERROR, MSG_ERROR, _("Cannot read directory contents"));
|
message (D_ERROR, MSG_ERROR, _("Cannot read directory contents"));
|
||||||
|
|
||||||
|
if (panel->dir.len == 0)
|
||||||
|
panel_set_current (panel, -1);
|
||||||
|
|
||||||
/* Restore old right path */
|
/* Restore old right path */
|
||||||
if (curdir != NULL)
|
if (curdir != NULL)
|
||||||
{
|
{
|
||||||
@ -4724,7 +4736,10 @@ panel_reload (WPanel *panel)
|
|||||||
message (D_ERROR, MSG_ERROR, _("Cannot read directory contents"));
|
message (D_ERROR, MSG_ERROR, _("Cannot read directory contents"));
|
||||||
|
|
||||||
panel->dirty = TRUE;
|
panel->dirty = TRUE;
|
||||||
if (panel->current >= panel->dir.len)
|
|
||||||
|
if (panel->dir.len == 0)
|
||||||
|
panel_set_current (panel, -1);
|
||||||
|
else if (panel->current >= panel->dir.len)
|
||||||
panel_set_current (panel, panel->dir.len - 1);
|
panel_set_current (panel, panel->dir.len - 1);
|
||||||
|
|
||||||
recalculate_panel_summary (panel);
|
recalculate_panel_summary (panel);
|
||||||
|
Loading…
Reference in New Issue
Block a user