Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

assistant_context_editor: Try to fix crash when trying to view patch (#25572)

Ben Kunkle014d9dfce15e
diff --git a/crates/assistant_context_editor/src/context_editor.rs b/crates/assistant_context_editor/src/context_editor.rs
index 12a522f56a3..5ecebd3e8d0 100644
--- a/crates/assistant_context_editor/src/context_editor.rs
+++ b/crates/assistant_context_editor/src/context_editor.rs
@@ -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(())
}