fix workspace/willRenameFiles buffer not editing
This commit is contained in:
parent
4c85a0dc71
commit
b44ff09043
3 changed files with 64 additions and 9 deletions
|
@ -1903,6 +1903,30 @@ impl Editor {
|
||||||
editor.update_lsp_data(false, Some(*buffer_id), window, cx);
|
editor.update_lsp_data(false, Some(*buffer_id), window, cx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
project::Event::UnsavedBufferEdit(buffer) => {
|
||||||
|
let Some(workspace) = editor.workspace() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
workspace.update(cx, |workspace, cx| {
|
||||||
|
Self::new_in_workspace_from_buffer(
|
||||||
|
workspace,
|
||||||
|
buffer.clone(),
|
||||||
|
window,
|
||||||
|
cx,
|
||||||
|
).detach_and_prompt_err(
|
||||||
|
"Failed to open buffer",
|
||||||
|
window,
|
||||||
|
cx,
|
||||||
|
|e, _, _| match e.error_code() {
|
||||||
|
ErrorCode::RemoteUpgradeRequired => Some(format!(
|
||||||
|
"The remote instance of Zed does not support this yet. It must be upgraded to {}",
|
||||||
|
e.error_tag("required").unwrap_or("the latest version")
|
||||||
|
)),
|
||||||
|
_ => None,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
|
@ -2584,6 +2608,23 @@ impl Editor {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn new_in_workspace_from_buffer(
|
||||||
|
workspace: &mut Workspace,
|
||||||
|
buffer: Entity<Buffer>,
|
||||||
|
window: &mut Window,
|
||||||
|
cx: &mut Context<Workspace>,
|
||||||
|
) -> Task<Result<Entity<Editor>>> {
|
||||||
|
let project = workspace.project().clone();
|
||||||
|
cx.spawn_in(window, async move |workspace, cx| {
|
||||||
|
workspace.update_in(cx, |workspace, window, cx| {
|
||||||
|
let editor =
|
||||||
|
cx.new(|cx| Editor::for_buffer(buffer, Some(project.clone()), window, cx));
|
||||||
|
workspace.add_item_to_active_pane(Box::new(editor.clone()), None, true, window, cx);
|
||||||
|
editor
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fn new_file_vertical(
|
fn new_file_vertical(
|
||||||
workspace: &mut Workspace,
|
workspace: &mut Workspace,
|
||||||
_: &workspace::NewFileSplitVertical,
|
_: &workspace::NewFileSplitVertical,
|
||||||
|
|
|
@ -3555,6 +3555,7 @@ pub enum LspStoreEvent {
|
||||||
edits: Vec<(lsp::Range, Snippet)>,
|
edits: Vec<(lsp::Range, Snippet)>,
|
||||||
most_recent_edit: clock::Lamport,
|
most_recent_edit: clock::Lamport,
|
||||||
},
|
},
|
||||||
|
UnsavedBufferEdit(Entity<Buffer>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize)]
|
#[derive(Clone, Debug, Serialize)]
|
||||||
|
@ -9210,15 +9211,24 @@ impl LspStore {
|
||||||
.log_err()
|
.log_err()
|
||||||
.flatten()?;
|
.flatten()?;
|
||||||
|
|
||||||
LocalLspStore::deserialize_workspace_edit(
|
if let Some(transaction) =
|
||||||
this.upgrade()?,
|
LocalLspStore::deserialize_workspace_edit(
|
||||||
edit,
|
this.upgrade()?,
|
||||||
false,
|
edit,
|
||||||
language_server.clone(),
|
false,
|
||||||
cx,
|
language_server.clone(),
|
||||||
)
|
cx,
|
||||||
.await
|
)
|
||||||
.ok();
|
.await
|
||||||
|
.ok()
|
||||||
|
{
|
||||||
|
for (buffer, _) in transaction.0 {
|
||||||
|
this.update(cx, |_, cx| {
|
||||||
|
cx.emit(LspStoreEvent::UnsavedBufferEdit(buffer));
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
Some(())
|
Some(())
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -326,6 +326,7 @@ pub enum Event {
|
||||||
RefreshCodeLens,
|
RefreshCodeLens,
|
||||||
RevealInProjectPanel(ProjectEntryId),
|
RevealInProjectPanel(ProjectEntryId),
|
||||||
SnippetEdit(BufferId, Vec<(lsp::Range, Snippet)>),
|
SnippetEdit(BufferId, Vec<(lsp::Range, Snippet)>),
|
||||||
|
UnsavedBufferEdit(Entity<Buffer>),
|
||||||
ExpandedAllForEntry(WorktreeId, ProjectEntryId),
|
ExpandedAllForEntry(WorktreeId, ProjectEntryId),
|
||||||
AgentLocationChanged,
|
AgentLocationChanged,
|
||||||
}
|
}
|
||||||
|
@ -2985,6 +2986,9 @@ impl Project {
|
||||||
cx.emit(Event::SnippetEdit(*buffer_id, edits.clone()))
|
cx.emit(Event::SnippetEdit(*buffer_id, edits.clone()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LspStoreEvent::UnsavedBufferEdit(buffer) => {
|
||||||
|
cx.emit(Event::UnsavedBufferEdit(buffer.clone()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue