From 583d85cf66a360e9a6bd631179c907ecaf9da7e4 Mon Sep 17 00:00:00 2001 From: Thorsten Ball Date: Thu, 22 Feb 2024 11:21:19 +0100 Subject: [PATCH] Do not add empty tasks to inventory (#8180) I ran into this when trying out which keybindings work and accidentally added empty tasks. They get then added to the task inventory and displayed in the picker. Release Notes: - Fixed empty tasks being added to the list of tasks when using `task: spawn` --------- Co-authored-by: Kirill --- crates/tasks_ui/src/modal.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/crates/tasks_ui/src/modal.rs b/crates/tasks_ui/src/modal.rs index af2b3813a1..de5cc5d596 100644 --- a/crates/tasks_ui/src/modal.rs +++ b/crates/tasks_ui/src/modal.rs @@ -180,16 +180,21 @@ impl PickerDelegate for TasksModalDelegate { fn confirm(&mut self, secondary: bool, cx: &mut ViewContext>) { let current_match_index = self.selected_index(); - let Some(task) = secondary - .then(|| self.spawn_oneshot(cx)) - .flatten() - .or_else(|| { - self.matches.get(current_match_index).map(|current_match| { - let ix = current_match.candidate_id; - self.candidates[ix].clone() - }) + + let task = if secondary { + if !self.last_prompt.trim().is_empty() { + self.spawn_oneshot(cx) + } else { + None + } + } else { + self.matches.get(current_match_index).map(|current_match| { + let ix = current_match.candidate_id; + self.candidates[ix].clone() }) - else { + }; + + let Some(task) = task else { return; };