mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-13 05:42:59 +00:00
Move prediction diff computation to background thread (#21862)
Release Notes: - N/A Co-authored-by: Thorsten <thorsten@zed.dev> Co-authored-by: Cole <cole@zed.dev> Co-authored-by: Bennet <bennet@zed.dev>
This commit is contained in:
parent
e8c72d91c3
commit
dd66a20d78
1 changed files with 34 additions and 27 deletions
|
@ -7,7 +7,8 @@ use client::Client;
|
|||
use collections::{HashMap, HashSet, VecDeque};
|
||||
use futures::AsyncReadExt;
|
||||
use gpui::{
|
||||
actions, AppContext, Context, EntityId, Global, Model, ModelContext, Subscription, Task,
|
||||
actions, AppContext, AsyncAppContext, Context, EntityId, Global, Model, ModelContext,
|
||||
Subscription, Task,
|
||||
};
|
||||
use http_client::{HttpClient, Method};
|
||||
use language::{
|
||||
|
@ -313,7 +314,9 @@ impl Zeta {
|
|||
path,
|
||||
input_events,
|
||||
input_excerpt,
|
||||
)?;
|
||||
&cx,
|
||||
)
|
||||
.await?;
|
||||
|
||||
this.update(&mut cx, |this, cx| {
|
||||
this.recent_completions
|
||||
|
@ -543,7 +546,10 @@ and then another
|
|||
path: Arc<Path>,
|
||||
input_events: String,
|
||||
input_excerpt: String,
|
||||
) -> Result<InlineCompletion> {
|
||||
cx: &AsyncAppContext,
|
||||
) -> Task<Result<InlineCompletion>> {
|
||||
let snapshot = snapshot.clone();
|
||||
cx.background_executor().spawn(async move {
|
||||
let content = output_excerpt.replace(CURSOR_MARKER, "");
|
||||
|
||||
let codefence_start = content
|
||||
|
@ -563,7 +569,7 @@ and then another
|
|||
.text_for_range(excerpt_range.clone())
|
||||
.collect::<String>();
|
||||
|
||||
let edits = Self::compute_edits(old_text, new_text, excerpt_range.start, snapshot);
|
||||
let edits = Self::compute_edits(old_text, new_text, excerpt_range.start, &snapshot);
|
||||
|
||||
Ok(InlineCompletion {
|
||||
id: InlineCompletionId::new(),
|
||||
|
@ -575,6 +581,7 @@ and then another
|
|||
input_excerpt: input_excerpt.into(),
|
||||
output_excerpt: output_excerpt.into(),
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
pub fn compute_edits(
|
||||
|
|
Loading…
Reference in a new issue