Skip to content

Commit

Permalink
Remove unused session_id from shutdown event
Browse files Browse the repository at this point in the history
  • Loading branch information
RemcoSmitsDev committed Dec 25, 2024
1 parent 3812f98 commit f3808da
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 21 deletions.
15 changes: 6 additions & 9 deletions crates/debugger_tools/src/dap_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,8 @@ impl LogStore {
this.projects.remove(&weak_project);
}),
cx.subscribe(project, |this, project, event, cx| match event {
project::Event::DebugClientStarted((session_id, client_id)) => {
project::Event::DebugClientStarted((_, client_id)) => {
this.add_debug_client(
*session_id,
*client_id,
project.update(cx, |project, cx| {
project
Expand All @@ -179,8 +178,8 @@ impl LogStore {
}),
);
}
project::Event::DebugClientShutdown((session_id, client_id)) => {
this.remove_debug_client(*session_id, *client_id, cx);
project::Event::DebugClientShutdown(client_id) => {
this.remove_debug_client(*client_id, cx);
}

_ => {}
Expand Down Expand Up @@ -290,7 +289,6 @@ impl LogStore {

fn add_debug_client(
&mut self,
session_id: DebugSessionId,
client_id: DebugAdapterClientId,
session_and_client: Option<(Model<DebugSession>, Arc<DebugAdapterClient>)>,
) -> Option<&mut DebugAdapterState> {
Expand All @@ -299,7 +297,7 @@ impl LogStore {
.entry(client_id)
.or_insert_with(DebugAdapterState::new);

if let Some((session, client)) = session_and_client {
if let Some((_, client)) = session_and_client {
let io_tx = self.rpc_tx.clone();

client.add_log_handler(
Expand Down Expand Up @@ -327,7 +325,6 @@ impl LogStore {

fn remove_debug_client(
&mut self,
session_id: DebugSessionId,
client_id: DebugAdapterClientId,
cx: &mut ModelContext<Self>,
) {
Expand Down Expand Up @@ -409,11 +406,11 @@ impl Render for DapLogToolbarItemView {
let menu_rows = menu_rows.clone();
ContextMenu::build(cx, move |mut menu, cx| {
for row in menu_rows.into_iter() {
menu = menu.header(format!("{} ({})", row.session_name, row.session_id.0));
menu = menu.header(format!("{}. {}", row.session_id.0, row.session_name));

for sub_item in row.clients.into_iter() {
menu = menu.label(format!(
"{} ({})",
"{}. {}",
sub_item.client_name, sub_item.client_id.0
));

Expand Down
2 changes: 1 addition & 1 deletion crates/debugger_ui/src/debugger_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl DebugPanel {
}
_ => unreachable!(),
},
project::Event::DebugClientShutdown((session_id, client_id)) => {
project::Event::DebugClientShutdown(client_id) => {
cx.emit(DebugPanelEvent::ClientShutdown(*client_id));

this.message_queue.remove(client_id);
Expand Down
16 changes: 6 additions & 10 deletions crates/project/src/dap_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ use util::{merge_json_value_into, ResultExt as _};

pub enum DapStoreEvent {
DebugClientStarted((DebugSessionId, DebugAdapterClientId)),
DebugClientShutdown((DebugSessionId, DebugAdapterClientId)),
DebugClientShutdown(DebugAdapterClientId),
DebugClientEvent {
session_id: DebugSessionId,
client_id: DebugAdapterClientId,
Expand Down Expand Up @@ -272,7 +272,7 @@ impl DapStore {
cx: &mut ModelContext<Self>,
) {
if let Some((session, _)) = self.client_by_id(client_id, cx) {
session.update(cx, |session, cx| {
session.update(cx, |session, _| {
session.update_capabilities(
client_id,
session.capabilities(client_id).merge(other.clone()),
Expand Down Expand Up @@ -716,7 +716,7 @@ impl DapStore {
// update the process id on the config, so when the `startDebugging` reverse request
// comes in we send another `attach` request with the already selected PID
// If we don't do this the user has to select the process twice if the adapter sends a `startDebugging` request
session.update(cx, |session, cx| {
session.update(cx, |session, _| {
session.update_configuration(|config| {
config.request = DebugRequestType::Attach(task::AttachConfig {
process_id: Some(process_id),
Expand Down Expand Up @@ -1396,10 +1396,7 @@ impl DapStore {
return Task::ready(Err(anyhow!("Could not find client: {:?}", client_id)));
};

cx.emit(DapStoreEvent::DebugClientShutdown((
session.read(cx).id(),
*client_id,
)));
cx.emit(DapStoreEvent::DebugClientShutdown(*client_id));

self.ignore_breakpoints.remove(client_id);
let capabilities = session.read(cx).capabilities(client_id);
Expand Down Expand Up @@ -1520,7 +1517,7 @@ impl DapStore {
this.update(&mut cx, |dap_store, cx| {
let session_id = DebugSessionId::from_proto(envelope.payload.session_id);
if let Some(session) = dap_store.session_by_id(&session_id) {
session.update(cx, |session, cx| {
session.update(cx, |session, _| {
session.update_capabilities(
&DebugAdapterClientId::from_proto(envelope.payload.client_id),
dap::proto_conversions::capabilities_from_proto(&envelope.payload),
Expand All @@ -1539,10 +1536,9 @@ impl DapStore {
) -> Result<()> {
this.update(&mut cx, |dap_store, cx| {
if matches!(dap_store.mode, DapStoreMode::Remote(_)) {
let session_id = DebugSessionId::from_proto(envelope.payload.session_id);
let client_id = DebugAdapterClientId::from_proto(envelope.payload.client_id);

cx.emit(DapStoreEvent::DebugClientShutdown((session_id, client_id)));
cx.emit(DapStoreEvent::DebugClientShutdown(client_id));
cx.notify();
}
})
Expand Down
2 changes: 1 addition & 1 deletion crates/project/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ pub enum Event {
LanguageServerPrompt(LanguageServerPromptRequest),
LanguageNotFound(Model<Buffer>),
DebugClientStarted((DebugSessionId, DebugAdapterClientId)),
DebugClientShutdown((DebugSessionId, DebugAdapterClientId)),
DebugClientShutdown(DebugAdapterClientId),
SetDebugClient(SetDebuggerPanelItem),
ActiveDebugLineChanged,
DebugClientEvent {
Expand Down

0 comments on commit f3808da

Please sign in to comment.