From 554f0f891d572de5a105ac57497df768e2f2d904 Mon Sep 17 00:00:00 2001 From: Ingrid Date: Sun, 22 Sep 2024 13:15:44 +0200 Subject: [PATCH] only trim persistent state files if persistent state is enabled --- helix-term/src/application.rs | 54 +++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 0491b96af..0f7248e4e 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -290,30 +290,36 @@ 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(), - ); + if config.load().editor.persistence.old_files { + 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(), + ); + } + if config.load().editor.persistence.commands { + 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(), + ); + } + if config.load().editor.persistence.search { + 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,