Fetch code actions on cursor movement instead of on-demand

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra 2022-02-11 14:41:19 +01:00
parent 763d57c94a
commit 2fcdcac080
9 changed files with 134 additions and 70 deletions

View file

@ -221,7 +221,7 @@ impl Pane {
let task = workspace.load_path(project_path, cx);
cx.spawn(|workspace, mut cx| async move {
let item = task.await;
if let Some(pane) = cx.read(|cx| pane.upgrade(cx)) {
if let Some(pane) = pane.upgrade(&cx) {
if let Some(item) = item.log_err() {
workspace.update(&mut cx, |workspace, cx| {
pane.update(cx, |p, _| p.nav_history.borrow_mut().set_mode(mode));

View file

@ -326,7 +326,7 @@ impl<T: Item> WeakItemHandle for WeakModelHandle<T> {
}
fn upgrade(&self, cx: &AppContext) -> Option<Box<dyn ItemHandle>> {
WeakModelHandle::<T>::upgrade(*self, cx).map(|i| Box::new(i) as Box<dyn ItemHandle>)
WeakModelHandle::<T>::upgrade(self, cx).map(|i| Box::new(i) as Box<dyn ItemHandle>)
}
}
@ -591,7 +591,7 @@ impl Workspace {
while stream.recv().await.is_some() {
cx.update(|cx| {
if let Some(this) = this.upgrade(&cx) {
if let Some(this) = this.upgrade(cx) {
this.update(cx, |_, cx| cx.notify());
}
})
@ -774,7 +774,7 @@ impl Workspace {
let item = load_task.await?;
this.update(&mut cx, |this, cx| {
let pane = pane
.upgrade(&cx)
.upgrade(cx)
.ok_or_else(|| anyhow!("could not upgrade pane reference"))?;
Ok(this.open_item_in_pane(item, &pane, cx))
})