🎨 Return an option task from confirm_completion

This commit is contained in:
Max Brunsfeld 2022-02-01 14:27:01 -08:00
parent 55cc7bb868
commit 1371a20e58
4 changed files with 36 additions and 54 deletions

View file

@ -1,7 +1,7 @@
mod anchor;
pub use anchor::{Anchor, AnchorRangeExt};
use anyhow::{anyhow, Result};
use anyhow::Result;
use clock::ReplicaId;
use collections::{HashMap, HashSet};
use gpui::{AppContext, Entity, ModelContext, ModelHandle, Task};
@ -933,17 +933,13 @@ impl MultiBuffer {
&self,
completion: Completion<Anchor>,
cx: &mut ModelContext<Self>,
) -> Task<Result<()>> {
let buffer = if let Some(buffer) = self
) -> Option<Task<Result<()>>> {
let buffer = self
.buffers
.borrow()
.get(&completion.old_range.start.buffer_id)
{
buffer.buffer.clone()
} else {
return Task::ready(Err(anyhow!("completion cannot be applied to any buffer")));
};
.get(&completion.old_range.start.buffer_id)?
.buffer
.clone();
buffer.update(cx, |buffer, cx| {
buffer.apply_completion(
Completion {