This commit is contained in:
Antonio Scandurra 2022-01-31 19:12:35 +01:00
parent bd2527e691
commit 03bcbdc33d
3 changed files with 122 additions and 0 deletions

View file

@ -5,6 +5,7 @@ use anyhow::Result;
use clock::ReplicaId;
use collections::{HashMap, HashSet};
use gpui::{AppContext, Entity, ModelContext, ModelHandle, Task};
pub use language::Completion;
use language::{
Buffer, BufferChunks, BufferSnapshot, Chunk, DiagnosticEntry, Event, File, Language, Outline,
OutlineItem, Selection, ToOffset as _, ToPoint as _, TransactionId,
@ -847,6 +848,18 @@ impl MultiBuffer {
})
}
pub fn completions<T>(
&self,
position: T,
cx: &mut ModelContext<Self>,
) -> Task<Result<Vec<Completion>>>
where
T: ToOffset,
{
let (buffer, text_anchor) = self.text_anchor_for_position(position, cx);
buffer.update(cx, |buffer, cx| buffer.completions(text_anchor, cx))
}
pub fn language<'a>(&self, cx: &'a AppContext) -> Option<&'a Arc<Language>> {
self.buffers
.borrow()