From 9c6ccaffe361be25a8a6ac07e02fdd35b05d3532 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 6 Aug 2024 17:25:13 +0200 Subject: [PATCH] Allow user to restart transformation after stopping without a diff (#15858) Release Notes: - N/A Co-authored-by: Jason --- crates/assistant/src/inline_assistant.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/assistant/src/inline_assistant.rs b/crates/assistant/src/inline_assistant.rs index 3e5ac1ba68..dd42613115 100644 --- a/crates/assistant/src/inline_assistant.rs +++ b/crates/assistant/src/inline_assistant.rs @@ -2036,6 +2036,12 @@ struct Diff { inserted_row_ranges: Vec>, } +impl Diff { + fn is_empty(&self) -> bool { + self.deleted_row_ranges.is_empty() && self.inserted_row_ranges.is_empty() + } +} + impl EventEmitter for Codegen {} impl Codegen { @@ -2467,7 +2473,11 @@ impl Codegen { pub fn stop(&mut self, cx: &mut ModelContext) { self.last_equal_ranges.clear(); - self.status = CodegenStatus::Done; + if self.diff.is_empty() { + self.status = CodegenStatus::Idle; + } else { + self.status = CodegenStatus::Done; + } self.generation = Task::ready(()); cx.emit(CodegenEvent::Finished); cx.notify();