diff options
author | Jeff Zhao <jeff.no.zhao@gmail.com> | 2021-08-19 15:50:51 -0400 |
---|---|---|
committer | Jeff Zhao <jeff.no.zhao@gmail.com> | 2021-08-19 15:50:51 -0400 |
commit | 8439bb52409a9ed10bdecae63d37d7380d51ed08 (patch) | |
tree | 4fc10212c06e778295cad9611c3273fe156904fa | |
parent | 1f603a983c57f07872dfd1b4f948e1fb8c9eccdb (diff) |
counting file lazily on previously selected file instead of current
-rw-r--r-- | src/commands/cursor_move.rs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/commands/cursor_move.rs b/src/commands/cursor_move.rs index 3bded3c..820e5fa 100644 --- a/src/commands/cursor_move.rs +++ b/src/commands/cursor_move.rs @@ -3,17 +3,6 @@ use crate::error::JoshutoResult; use crate::ui::TuiBackend; pub fn cursor_move(new_index: usize, context: &mut AppContext) -> JoshutoResult<()> { - let mut new_index = new_index; - if let Some(curr_list) = context.tab_context_mut().curr_tab_mut().curr_list_mut() { - if !curr_list.is_empty() { - let dir_len = curr_list.len(); - if new_index >= dir_len { - new_index = dir_len - 1; - } - curr_list.index = Some(new_index); - } - } - let directory_size = match context .tab_context_ref() .curr_tab_ref() @@ -43,6 +32,17 @@ pub fn cursor_move(new_index: usize, context: &mut AppContext) -> JoshutoResult< curr_entry.metadata.update_directory_size(s); } } + + let mut new_index = new_index; + if let Some(curr_list) = context.tab_context_mut().curr_tab_mut().curr_list_mut() { + if !curr_list.is_empty() { + let dir_len = curr_list.len(); + if new_index >= dir_len { + new_index = dir_len - 1; + } + curr_list.index = Some(new_index); + } + } Ok(()) } |