Revert to fix panic in inline assistant (#28428)
This reverts commit f12a554f86
, which
introduced a panic in inline assistant (cc @mgsloan) - I'm not sure what
the motivation was for that change, but I figure we can revert to fix
the inline assistant now and deal with that later. 😄
Panic was:
> Thread "main" panicked with "cannot read workspace::Workspace while it
is already being updated" at
/Users/rtfeldman/code/zed/crates/gpui/src/app/entity_map.rs:139:32
Release Notes:
- N/A
This commit is contained in:
parent
6d7fef6fd3
commit
9d0fe164a7
6 changed files with 40 additions and 32 deletions
|
@ -262,7 +262,13 @@ impl InlineAssistant {
|
|||
}
|
||||
InlineAssistTarget::Terminal(active_terminal) => {
|
||||
TerminalInlineAssistant::update_global(cx, |assistant, cx| {
|
||||
assistant.assist(&active_terminal, cx.entity(), thread_store, window, cx)
|
||||
assistant.assist(
|
||||
&active_terminal,
|
||||
cx.entity().downgrade(),
|
||||
thread_store,
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
}
|
||||
};
|
||||
|
@ -316,13 +322,6 @@ impl InlineAssistant {
|
|||
window: &mut Window,
|
||||
cx: &mut App,
|
||||
) {
|
||||
let Some(project) = workspace
|
||||
.upgrade()
|
||||
.map(|workspace| workspace.read(cx).project().downgrade())
|
||||
else {
|
||||
return;
|
||||
};
|
||||
|
||||
let (snapshot, initial_selections) = editor.update(cx, |editor, cx| {
|
||||
(
|
||||
editor.snapshot(window, cx),
|
||||
|
@ -426,7 +425,7 @@ impl InlineAssistant {
|
|||
for range in codegen_ranges {
|
||||
let assist_id = self.next_assist_id.post_inc();
|
||||
let context_store =
|
||||
cx.new(|_cx| ContextStore::new(project.clone(), thread_store.clone()));
|
||||
cx.new(|_cx| ContextStore::new(workspace.clone(), thread_store.clone()));
|
||||
let codegen = cx.new(|cx| {
|
||||
BufferCodegen::new(
|
||||
editor.read(cx).buffer().clone(),
|
||||
|
@ -520,7 +519,7 @@ impl InlineAssistant {
|
|||
initial_prompt: String,
|
||||
initial_transaction_id: Option<TransactionId>,
|
||||
focus: bool,
|
||||
workspace: Entity<Workspace>,
|
||||
workspace: WeakEntity<Workspace>,
|
||||
thread_store: Option<WeakEntity<ThreadStore>>,
|
||||
window: &mut Window,
|
||||
cx: &mut App,
|
||||
|
@ -538,8 +537,8 @@ impl InlineAssistant {
|
|||
range.end = range.end.bias_right(&snapshot);
|
||||
}
|
||||
|
||||
let project = workspace.read(cx).project().downgrade();
|
||||
let context_store = cx.new(|_cx| ContextStore::new(project, thread_store.clone()));
|
||||
let context_store =
|
||||
cx.new(|_cx| ContextStore::new(workspace.clone(), thread_store.clone()));
|
||||
|
||||
let codegen = cx.new(|cx| {
|
||||
BufferCodegen::new(
|
||||
|
@ -563,7 +562,7 @@ impl InlineAssistant {
|
|||
codegen.clone(),
|
||||
self.fs.clone(),
|
||||
context_store,
|
||||
workspace.downgrade(),
|
||||
workspace.clone(),
|
||||
thread_store,
|
||||
window,
|
||||
cx,
|
||||
|
@ -590,7 +589,7 @@ impl InlineAssistant {
|
|||
end_block_id,
|
||||
range,
|
||||
codegen.clone(),
|
||||
workspace.downgrade(),
|
||||
workspace.clone(),
|
||||
window,
|
||||
cx,
|
||||
),
|
||||
|
@ -1780,7 +1779,6 @@ impl CodeActionProvider for AssistantCodeActionProvider {
|
|||
let workspace = self.workspace.clone();
|
||||
let thread_store = self.thread_store.clone();
|
||||
window.spawn(cx, async move |cx| {
|
||||
let workspace = workspace.upgrade().context("workspace was released")?;
|
||||
let editor = editor.upgrade().context("editor was released")?;
|
||||
let range = editor
|
||||
.update(cx, |editor, cx| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue