From 344d05045d208f55563c6ff513edc1e1698d141d Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 23 Dec 2022 12:26:48 +0100 Subject: [PATCH] Avoid hanging waiting for operations when buffer has none --- crates/project/src/project.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index dfd7b4fbf11e71e577da3c08eb29f873440017da..ca1b988d059102d7fe99ddd53488085640b1ea78 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -6255,16 +6255,19 @@ fn split_operations( #[cfg(not(any(test, feature = "test-support")))] const CHUNK_SIZE: usize = 100; + let mut done = false; std::iter::from_fn(move || { - if operations.is_empty() { + if done { return None; } - Some( - operations - .drain(..cmp::min(CHUNK_SIZE, operations.len())) - .collect(), - ) + let operations = operations + .drain(..cmp::min(CHUNK_SIZE, operations.len())) + .collect::>(); + if operations.is_empty() { + done = true; + } + Some(operations) }) }