Allow user to restart transformation after stopping without a diff (#15858)

Release Notes:

- N/A

Co-authored-by: Jason <jason@zed.dev>
This commit is contained in:
Antonio Scandurra 2024-08-06 17:25:13 +02:00 committed by GitHub
parent 411934bb61
commit 9c6ccaffe3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2036,6 +2036,12 @@ struct Diff {
inserted_row_ranges: Vec<RangeInclusive<Anchor>>,
}
impl Diff {
fn is_empty(&self) -> bool {
self.deleted_row_ranges.is_empty() && self.inserted_row_ranges.is_empty()
}
}
impl EventEmitter<CodegenEvent> for Codegen {}
impl Codegen {
@ -2467,7 +2473,11 @@ impl Codegen {
pub fn stop(&mut self, cx: &mut ModelContext<Self>) {
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();