Make Buffer::apply_ops infallible (#18089)

This PR makes the `Buffer::apply_ops` method infallible for
`text::Buffer` and `language::Buffer`.

We discovered that `text::Buffer::apply_ops` was only fallible due to
`apply_undo`, which didn't actually need to be fallible.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-09-19 13:14:15 -04:00 committed by GitHub
parent 8074fba76b
commit 1fc391f696
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 85 additions and 108 deletions

View file

@ -644,7 +644,7 @@ impl BufferStore {
}
hash_map::Entry::Occupied(mut entry) => {
if let OpenBuffer::Operations(operations) = entry.get_mut() {
buffer.update(cx, |b, cx| b.apply_ops(operations.drain(..), cx))?;
buffer.update(cx, |b, cx| b.apply_ops(operations.drain(..), cx));
} else if entry.get().upgrade().is_some() {
if is_remote {
return Ok(());
@ -1051,12 +1051,12 @@ impl BufferStore {
match this.opened_buffers.entry(buffer_id) {
hash_map::Entry::Occupied(mut e) => match e.get_mut() {
OpenBuffer::Strong(buffer) => {
buffer.update(cx, |buffer, cx| buffer.apply_ops(ops, cx))?;
buffer.update(cx, |buffer, cx| buffer.apply_ops(ops, cx));
}
OpenBuffer::Operations(operations) => operations.extend_from_slice(&ops),
OpenBuffer::Weak(buffer) => {
if let Some(buffer) = buffer.upgrade() {
buffer.update(cx, |buffer, cx| buffer.apply_ops(ops, cx))?;
buffer.update(cx, |buffer, cx| buffer.apply_ops(ops, cx));
}
}
},
@ -1217,7 +1217,8 @@ impl BufferStore {
.into_iter()
.map(language::proto::deserialize_operation)
.collect::<Result<Vec<_>>>()?;
buffer.update(cx, |buffer, cx| buffer.apply_ops(operations, cx))
buffer.update(cx, |buffer, cx| buffer.apply_ops(operations, cx));
anyhow::Ok(())
});
if let Err(error) = result {