Improve formatting of function autocompletion labels in Rust

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Max Brunsfeld <max@zed.dev>
This commit is contained in:
Antonio Scandurra 2022-02-02 18:43:55 +01:00
parent 8d7815456c
commit 8149bcbb13
7 changed files with 63 additions and 21 deletions

View file

@ -1752,11 +1752,13 @@ impl Project {
.get(&sender_id)
.and_then(|shared_buffers| shared_buffers.get(&envelope.payload.buffer_id).cloned())
.ok_or_else(|| anyhow!("unknown buffer id {}", envelope.payload.buffer_id))?;
let language = buffer.read(cx).language();
let completion = language::proto::deserialize_completion(
envelope
.payload
.completion
.ok_or_else(|| anyhow!("invalid position"))?,
language,
)?;
cx.spawn(|_, mut cx| async move {
match buffer

View file

@ -14,7 +14,9 @@ use gpui::{
executor, AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, MutableAppContext,
Task,
};
use language::{Anchor, Buffer, Completion, DiagnosticEntry, Operation, PointUtf16, Rope};
use language::{
Anchor, Buffer, Completion, DiagnosticEntry, Language, Operation, PointUtf16, Rope,
};
use lazy_static::lazy_static;
use parking_lot::Mutex;
use postage::{
@ -1425,6 +1427,7 @@ impl language::File for File {
&self,
buffer_id: u64,
position: Anchor,
language: Option<Arc<Language>>,
cx: &mut MutableAppContext,
) -> Task<Result<Vec<Completion<Anchor>>>> {
let worktree = self.worktree.read(cx);
@ -1448,7 +1451,9 @@ impl language::File for File {
response
.completions
.into_iter()
.map(language::proto::deserialize_completion)
.map(|completion| {
language::proto::deserialize_completion(completion, language.as_ref())
})
.collect()
})
}