add trim config options for persistence

pull/9143/head
Ingrid 7 months ago
parent 95573b5267
commit afa0f095d9

@ -289,6 +289,32 @@ impl Application {
])
.context("build signal handler")?;
let jobs = Jobs::new();
let file_trim = config.load().editor.persistence_old_files_trim;
jobs.add(
Job::new(async move {
persistence::trim_file_history(file_trim);
Ok(())
})
.wait_before_exiting(),
);
let commands_trim = config.load().editor.persistence_commands_trim;
jobs.add(
Job::new(async move {
persistence::trim_command_history(commands_trim);
Ok(())
})
.wait_before_exiting(),
);
let search_trim = config.load().editor.persistence_search_trim;
jobs.add(
Job::new(async move {
persistence::trim_search_history(search_trim);
Ok(())
})
.wait_before_exiting(),
);
let app = Self {
compositor,
terminal,
@ -300,30 +326,9 @@ impl Application {
syn_loader,
signals,
jobs: Jobs::new(),
jobs,
lsp_progress: LspProgressMap::new(),
};
app.jobs.add(
Job::new(async {
persistence::trim_file_history(5);
Ok(())
})
.wait_before_exiting(),
);
app.jobs.add(
Job::new(async {
persistence::trim_command_history(5);
Ok(())
})
.wait_before_exiting(),
);
app.jobs.add(
Job::new(async {
persistence::trim_search_history(5);
Ok(())
})
.wait_before_exiting(),
);
Ok(app)
}

@ -355,6 +355,9 @@ pub struct Config {
pub persist_search: bool,
pub persist_clipboard: bool,
pub persistence_file_exclusions: Vec<EqRegex>,
pub persistence_old_files_trim: usize,
pub persistence_commands_trim: usize,
pub persistence_search_trim: usize,
}
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, Eq, PartialOrd, Ord)]
@ -998,6 +1001,9 @@ impl Default for Config {
.iter()
.map(|s| Regex::new(s).unwrap().into())
.collect(),
persistence_old_files_trim: 100,
persistence_commands_trim: 100,
persistence_search_trim: 100,
}
}
}

Loading…
Cancel
Save