@@ -1087,7 +1087,7 @@ impl ContextEditor {
patch: AssistantPatch,
mut cx: AsyncWindowContext,
) -> Result<()> {
- let project = this.update(&mut cx, |this, _| this.project.clone())?;
+ let project = this.read_with(&cx, |this, _| this.project.clone())?;
let resolved_patch = patch.resolve(project.clone(), &mut cx).await;
let editor = cx.new_window_entity(|window, cx| {
@@ -1112,7 +1112,7 @@ impl ContextEditor {
editor
})?;
- this.update_in(&mut cx, |this, window, cx| {
+ this.update(&mut cx, |this, _| {
if let Some(patch_state) = this.patches.get_mut(&patch.range) {
patch_state.editor = Some(PatchEditorState {
editor: editor.downgrade(),
@@ -1120,19 +1120,12 @@ impl ContextEditor {
});
patch_state.update_task.take();
}
-
- this.workspace
- .update(cx, |workspace, cx| {
- workspace.add_item_to_active_pane(
- Box::new(editor.clone()),
- None,
- false,
- window,
- cx,
- )
- })
- .log_err();
})?;
+ this.read_with(&cx, |this, _| this.workspace.clone())?
+ .update_in(&mut cx, |workspace, window, cx| {
+ workspace.add_item_to_active_pane(Box::new(editor.clone()), None, false, window, cx)
+ })
+ .log_err();
Ok(())
}