Send copilot log messages into the log panel
This commit is contained in:
parent
5e1b284846
commit
7bc4f0bc11
2 changed files with 19 additions and 16 deletions
|
@ -14,10 +14,9 @@ use language::{
|
||||||
point_from_lsp, point_to_lsp, Anchor, Bias, Buffer, BufferSnapshot, Language,
|
point_from_lsp, point_to_lsp, Anchor, Bias, Buffer, BufferSnapshot, Language,
|
||||||
LanguageServerName, PointUtf16, ToPointUtf16,
|
LanguageServerName, PointUtf16, ToPointUtf16,
|
||||||
};
|
};
|
||||||
use log::{debug, error};
|
|
||||||
use lsp::{LanguageServer, LanguageServerBinary, LanguageServerId};
|
use lsp::{LanguageServer, LanguageServerBinary, LanguageServerId};
|
||||||
use node_runtime::NodeRuntime;
|
use node_runtime::NodeRuntime;
|
||||||
use request::{LogMessage, StatusNotification};
|
use request::StatusNotification;
|
||||||
use settings::SettingsStore;
|
use settings::SettingsStore;
|
||||||
use smol::{fs, io::BufReader, stream::StreamExt};
|
use smol::{fs, io::BufReader, stream::StreamExt};
|
||||||
use std::{
|
use std::{
|
||||||
|
@ -391,20 +390,6 @@ impl Copilot {
|
||||||
let server =
|
let server =
|
||||||
LanguageServer::new(new_server_id, binary, Path::new("/"), None, cx.clone())?;
|
LanguageServer::new(new_server_id, binary, Path::new("/"), None, cx.clone())?;
|
||||||
|
|
||||||
server
|
|
||||||
.on_notification::<LogMessage, _>(|params, _cx| {
|
|
||||||
match params.level {
|
|
||||||
// Copilot is pretty aggressive about logging
|
|
||||||
0 => debug!("copilot: {}", params.message),
|
|
||||||
1 => debug!("copilot: {}", params.message),
|
|
||||||
_ => error!("copilot: {}", params.message),
|
|
||||||
}
|
|
||||||
|
|
||||||
debug!("copilot metadata: {}", params.metadata_str);
|
|
||||||
debug!("copilot extra: {:?}", params.extra);
|
|
||||||
})
|
|
||||||
.detach();
|
|
||||||
|
|
||||||
server
|
server
|
||||||
.on_notification::<StatusNotification, _>(
|
.on_notification::<StatusNotification, _>(
|
||||||
|_, _| { /* Silence the notification */ },
|
|_, _| { /* Silence the notification */ },
|
||||||
|
|
|
@ -150,6 +150,7 @@ pub struct Project {
|
||||||
_maintain_workspace_config: Task<()>,
|
_maintain_workspace_config: Task<()>,
|
||||||
terminals: Terminals,
|
terminals: Terminals,
|
||||||
copilot_lsp_subscription: Option<gpui::Subscription>,
|
copilot_lsp_subscription: Option<gpui::Subscription>,
|
||||||
|
copilot_log_subscription: Option<lsp::Subscription>,
|
||||||
current_lsp_settings: HashMap<Arc<str>, LspSettings>,
|
current_lsp_settings: HashMap<Arc<str>, LspSettings>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -664,6 +665,7 @@ impl Project {
|
||||||
local_handles: Vec::new(),
|
local_handles: Vec::new(),
|
||||||
},
|
},
|
||||||
copilot_lsp_subscription,
|
copilot_lsp_subscription,
|
||||||
|
copilot_log_subscription: None,
|
||||||
current_lsp_settings: settings::get::<ProjectSettings>(cx).lsp.clone(),
|
current_lsp_settings: settings::get::<ProjectSettings>(cx).lsp.clone(),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -760,6 +762,7 @@ impl Project {
|
||||||
local_handles: Vec::new(),
|
local_handles: Vec::new(),
|
||||||
},
|
},
|
||||||
copilot_lsp_subscription,
|
copilot_lsp_subscription,
|
||||||
|
copilot_log_subscription: None,
|
||||||
current_lsp_settings: settings::get::<ProjectSettings>(cx).lsp.clone(),
|
current_lsp_settings: settings::get::<ProjectSettings>(cx).lsp.clone(),
|
||||||
};
|
};
|
||||||
for worktree in worktrees {
|
for worktree in worktrees {
|
||||||
|
@ -8041,6 +8044,21 @@ fn subscribe_for_copilot_events(
|
||||||
if let hash_map::Entry::Vacant(v) =
|
if let hash_map::Entry::Vacant(v) =
|
||||||
project.supplementary_language_servers.entry(new_server_id)
|
project.supplementary_language_servers.entry(new_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.copilot_log_subscription = Some(copilot_log_subscription);
|
||||||
v.insert((name.clone(), Arc::clone(copilot_server)));
|
v.insert((name.clone(), Arc::clone(copilot_server)));
|
||||||
cx.emit(Event::LanguageServerAdded(new_server_id));
|
cx.emit(Event::LanguageServerAdded(new_server_id));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue