Animate Zeta button while generating completions (#22899)
Release Notes: - N/A Co-authored-by: Thorsten <thorsten@zed.dev>
This commit is contained in:
parent
7d905d0791
commit
e64a56ffad
10 changed files with 106 additions and 29 deletions
|
@ -19,7 +19,7 @@ pub struct SupermavenCompletionProvider {
|
|||
buffer_id: Option<EntityId>,
|
||||
completion_id: Option<SupermavenCompletionStateId>,
|
||||
file_extension: Option<String>,
|
||||
pending_refresh: Task<Result<()>>,
|
||||
pending_refresh: Option<Task<Result<()>>>,
|
||||
}
|
||||
|
||||
impl SupermavenCompletionProvider {
|
||||
|
@ -29,7 +29,7 @@ impl SupermavenCompletionProvider {
|
|||
buffer_id: None,
|
||||
completion_id: None,
|
||||
file_extension: None,
|
||||
pending_refresh: Task::ready(Ok(())),
|
||||
pending_refresh: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -122,6 +122,10 @@ impl InlineCompletionProvider for SupermavenCompletionProvider {
|
|||
settings.inline_completions_enabled(language.as_ref(), file.map(|f| f.path().as_ref()), cx)
|
||||
}
|
||||
|
||||
fn is_refreshing(&self) -> bool {
|
||||
self.pending_refresh.is_some()
|
||||
}
|
||||
|
||||
fn refresh(
|
||||
&mut self,
|
||||
buffer_handle: Model<Buffer>,
|
||||
|
@ -135,7 +139,7 @@ impl InlineCompletionProvider for SupermavenCompletionProvider {
|
|||
return;
|
||||
};
|
||||
|
||||
self.pending_refresh = cx.spawn(|this, mut cx| async move {
|
||||
self.pending_refresh = Some(cx.spawn(|this, mut cx| async move {
|
||||
if debounce {
|
||||
cx.background_executor().timer(DEBOUNCE_TIMEOUT).await;
|
||||
}
|
||||
|
@ -152,11 +156,12 @@ impl InlineCompletionProvider for SupermavenCompletionProvider {
|
|||
.to_string(),
|
||||
)
|
||||
});
|
||||
this.pending_refresh = None;
|
||||
cx.notify();
|
||||
})?;
|
||||
}
|
||||
Ok(())
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
fn cycle(
|
||||
|
@ -169,12 +174,12 @@ impl InlineCompletionProvider for SupermavenCompletionProvider {
|
|||
}
|
||||
|
||||
fn accept(&mut self, _cx: &mut ModelContext<Self>) {
|
||||
self.pending_refresh = Task::ready(Ok(()));
|
||||
self.pending_refresh = None;
|
||||
self.completion_id = None;
|
||||
}
|
||||
|
||||
fn discard(&mut self, _cx: &mut ModelContext<Self>) {
|
||||
self.pending_refresh = Task::ready(Ok(()));
|
||||
self.pending_refresh = None;
|
||||
self.completion_id = None;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue