Skip to content

Commit

Permalink
counting file lazily on previously selected file instead of current
Browse files Browse the repository at this point in the history
  • Loading branch information
kamiyaa committed Aug 19, 2021
1 parent 1f603a9 commit 8439bb5
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/commands/cursor_move.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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(())
}

Expand Down

0 comments on commit 8439bb5

Please sign in to comment.