summaryrefslogtreecommitdiffstats
path: root/src/commands/show_hidden.rs
blob: fdebba66a144339c15fe41695c130ef7e0df5cc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use crate::context::AppContext;
use crate::error::AppResult;
use crate::history::DirectoryHistory;

use super::reload;

pub fn _toggle_hidden(context: &mut AppContext) {
    let opposite = !context.config_ref().display_options_ref().show_hidden();
    context
        .config_mut()
        .display_options_mut()
        .set_show_hidden(opposite);

    for (_, tab) in context.tab_context_mut().iter_mut() {
        tab.history_mut().depreciate_all_entries();
        if let Some(s) = tab.curr_list_mut() {
            s.depreciate();
        }
    }
}

pub fn toggle_hidden(context: &mut AppContext) -> AppResult {
    _toggle_hidden(context);
    reload::soft_reload_curr_tab(context)?;
    Ok(())
}