From 2003159d322a96165ab949051c004c456de5be11 Mon Sep 17 00:00:00 2001 From: sigoden Date: Wed, 27 Nov 2024 09:16:06 +0800 Subject: feat: handle Ctrl+C during every spinner in REPL (#1014) --- src/config/input.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/config') diff --git a/src/config/input.rs b/src/config/input.rs index 5db172f..c527cfb 100644 --- a/src/config/input.rs +++ b/src/config/input.rs @@ -63,7 +63,6 @@ impl Input { paths: Vec, role: Option, ) -> Result { - let spinner = create_spinner("Loading files").await; let mut raw_paths = vec![]; let mut local_paths = vec![]; let mut remote_urls = vec![]; @@ -82,7 +81,6 @@ impl Input { } } let ret = load_documents(config, local_paths, remote_urls).await; - spinner.stop(); let (files, medias, data_urls) = ret.context("Failed to load files")?; let mut texts = vec![]; if !raw_text.is_empty() { @@ -112,6 +110,21 @@ impl Input { }) } + pub async fn from_files_with_spinner( + config: &GlobalConfig, + raw_text: &str, + paths: Vec, + role: Option, + abort_signal: AbortSignal, + ) -> Result { + abortable_run_with_spinner( + Input::from_files(config, raw_text, paths, role), + "Loading files", + abort_signal, + ) + .await + } + pub fn is_empty(&self) -> bool { self.text.is_empty() && self.medias.is_empty() } -- cgit v1.2.3