mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-31 00:54:13 +03:00
Avoid hanging waiting for operations when buffer has none
This commit is contained in:
parent
75803d8dbb
commit
344d05045d
@ -6255,16 +6255,19 @@ fn split_operations(
|
|||||||
#[cfg(not(any(test, feature = "test-support")))]
|
#[cfg(not(any(test, feature = "test-support")))]
|
||||||
const CHUNK_SIZE: usize = 100;
|
const CHUNK_SIZE: usize = 100;
|
||||||
|
|
||||||
|
let mut done = false;
|
||||||
std::iter::from_fn(move || {
|
std::iter::from_fn(move || {
|
||||||
if operations.is_empty() {
|
if done {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(
|
let operations = operations
|
||||||
operations
|
.drain(..cmp::min(CHUNK_SIZE, operations.len()))
|
||||||
.drain(..cmp::min(CHUNK_SIZE, operations.len()))
|
.collect::<Vec<_>>();
|
||||||
.collect(),
|
if operations.is_empty() {
|
||||||
)
|
done = true;
|
||||||
|
}
|
||||||
|
Some(operations)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user