Merge branch 'main' into allow-following-outside-of-projects
This commit is contained in:
commit
a8b35eb8f5
147 changed files with 5383 additions and 1726 deletions
|
@ -2273,11 +2273,13 @@ impl Project {
|
|||
};
|
||||
|
||||
for (_, _, server) in self.language_servers_for_worktree(worktree_id) {
|
||||
let text = include_text(server.as_ref()).then(|| buffer.read(cx).text());
|
||||
|
||||
server
|
||||
.notify::<lsp::notification::DidSaveTextDocument>(
|
||||
lsp::DidSaveTextDocumentParams {
|
||||
text_document: text_document.clone(),
|
||||
text: None,
|
||||
text,
|
||||
},
|
||||
)
|
||||
.log_err();
|
||||
|
@ -8034,24 +8036,27 @@ fn subscribe_for_copilot_events(
|
|||
copilot::Event::CopilotLanguageServerStarted => {
|
||||
match copilot.read(cx).language_server() {
|
||||
Some((name, copilot_server)) => {
|
||||
let new_server_id = copilot_server.server_id();
|
||||
let weak_project = cx.weak_handle();
|
||||
let copilot_log_subscription = copilot_server
|
||||
.on_notification::<copilot::request::LogMessage, _>(
|
||||
move |params, mut cx| {
|
||||
if let Some(project) = weak_project.upgrade(&mut cx) {
|
||||
project.update(&mut cx, |_, cx| {
|
||||
cx.emit(Event::LanguageServerLog(
|
||||
new_server_id,
|
||||
params.message,
|
||||
));
|
||||
})
|
||||
}
|
||||
},
|
||||
);
|
||||
project.supplementary_language_servers.insert(new_server_id, (name.clone(), Arc::clone(copilot_server)));
|
||||
project.copilot_log_subscription = Some(copilot_log_subscription);
|
||||
cx.emit(Event::LanguageServerAdded(new_server_id));
|
||||
// Another event wants to re-add the server that was already added and subscribed to, avoid doing it again.
|
||||
if !copilot_server.has_notification_handler::<copilot::request::LogMessage>() {
|
||||
let new_server_id = copilot_server.server_id();
|
||||
let weak_project = cx.weak_handle();
|
||||
let copilot_log_subscription = copilot_server
|
||||
.on_notification::<copilot::request::LogMessage, _>(
|
||||
move |params, mut cx| {
|
||||
if let Some(project) = weak_project.upgrade(&mut cx) {
|
||||
project.update(&mut cx, |_, cx| {
|
||||
cx.emit(Event::LanguageServerLog(
|
||||
new_server_id,
|
||||
params.message,
|
||||
));
|
||||
})
|
||||
}
|
||||
},
|
||||
);
|
||||
project.supplementary_language_servers.insert(new_server_id, (name.clone(), Arc::clone(copilot_server)));
|
||||
project.copilot_log_subscription = Some(copilot_log_subscription);
|
||||
cx.emit(Event::LanguageServerAdded(new_server_id));
|
||||
}
|
||||
}
|
||||
None => debug_panic!("Received Copilot language server started event, but no language server is running"),
|
||||
}
|
||||
|
@ -8308,3 +8313,19 @@ async fn wait_for_loading_buffer(
|
|||
receiver.next().await;
|
||||
}
|
||||
}
|
||||
|
||||
fn include_text(server: &lsp::LanguageServer) -> bool {
|
||||
server
|
||||
.capabilities()
|
||||
.text_document_sync
|
||||
.as_ref()
|
||||
.and_then(|sync| match sync {
|
||||
lsp::TextDocumentSyncCapability::Kind(_) => None,
|
||||
lsp::TextDocumentSyncCapability::Options(options) => options.save.as_ref(),
|
||||
})
|
||||
.and_then(|save_options| match save_options {
|
||||
lsp::TextDocumentSyncSaveOptions::Supported(_) => None,
|
||||
lsp::TextDocumentSyncSaveOptions::SaveOptions(options) => options.include_text,
|
||||
})
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue