From 1b5a26716b7d9050334d8ded58fe2c6ae7fe0143 Mon Sep 17 00:00:00 2001 From: verdant Date: Tue, 28 Jul 2026 20:29:23 +0800 Subject: Reset view state only on successful directory load --- src/fm.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/fm.c b/src/fm.c index db4aed8..a112e13 100644 --- a/src/fm.c +++ b/src/fm.c @@ -371,12 +371,13 @@ fm_cd_up(fm_info *info) file_list *new_list = fm_getdir(info->cur, info->cwd); if (new_list) { info->cur = new_list; + info->cursor = 0; + info->top = 0; + info->bottom = info->windows[FM_PANE_LEFT]->height; + need_redraw = true; + } else { + return; } - - info->cursor = 0; - info->top = 0; - info->bottom = info->windows[FM_PANE_LEFT]->height; - need_redraw = true; } void @@ -410,11 +411,13 @@ fm_cd_down(fm_info *info) file_list *new_list = fm_getdir(info->cur, info->cwd); if (new_list) { info->cur = new_list; + info->cursor = 0; + info->top = 0; + need_redraw = true; + } else { + free(next_dir); + return; } - - info->cursor = 0; - info->top = 0; - need_redraw = true; } free(next_dir); -- cgit v1.2.3