Skip to content

Commit

Permalink
fix: update all lists viewports on sort method change (#492)
Browse files Browse the repository at this point in the history
  • Loading branch information
Akmadan23 authored Feb 20, 2024
1 parent f2a707e commit 8f1c36a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/commands/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,22 @@ pub fn toggle_reverse(context: &mut AppContext) -> AppResult {

fn refresh(context: &mut AppContext) -> AppResult {
reload::soft_reload_curr_tab(context)?;

let ui_context = context.ui_context_ref().clone();
let display_options = context.config_ref().display_options_ref().clone();
let curr_tab = context.tab_context_mut().curr_tab_mut();

macro_rules! update_viewport {
($x_list_mut: ident) => {
if let Some(list) = curr_tab.$x_list_mut() {
list.update_viewport(&ui_context, &display_options);
}
};
}

update_viewport!(curr_list_mut);
update_viewport!(parent_list_mut);
update_viewport!(child_list_mut);

Ok(())
}
2 changes: 1 addition & 1 deletion src/fs/dirlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl JoshutoDirList {
}
}

fn update_viewport(&mut self, ui_context: &UiContext, options: &DisplayOption) {
pub fn update_viewport(&mut self, ui_context: &UiContext, options: &DisplayOption) {
if let Some(ix) = self.index {
let height = ui_context.layout[0].height as usize;

Expand Down

0 comments on commit 8f1c36a

Please sign in to comment.