From ef3a6deb05f99ea29abc8353276cc7e61b299b2c Mon Sep 17 00:00:00 2001 From: Remco Smits Date: Sat, 1 Feb 2025 16:52:48 +0100 Subject: [PATCH] Improve the visibility of process entries (#105) Before this change it was impossible to see the command arguments, as the executable was to long. This changes that so we use the process name as executable name VSCode as seems to do this. So you could still see the arguments of the program. I also added a tooltip to see the correct executable + arguments. --- crates/debugger_ui/src/attach_modal.rs | 50 +++++++++++++++++++------- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/crates/debugger_ui/src/attach_modal.rs b/crates/debugger_ui/src/attach_modal.rs index feabb90d41..bbbcd61b11 100644 --- a/crates/debugger_ui/src/attach_modal.rs +++ b/crates/debugger_ui/src/attach_modal.rs @@ -7,7 +7,7 @@ use picker::{Picker, PickerDelegate}; use project::dap_store::DapStore; use std::sync::Arc; use sysinfo::System; -use ui::{prelude::*, Context}; +use ui::{prelude::*, Context, Tooltip}; use ui::{ListItem, ListItemSpacing}; use workspace::ModalView; @@ -15,7 +15,7 @@ use workspace::ModalView; struct Candidate { pid: u32, name: String, - command: String, + command: Vec, } pub(crate) struct AttachModalDelegate { @@ -152,9 +152,8 @@ impl PickerDelegate for AttachModalDelegate { command: process .cmd() .iter() - .map(|s| s.to_string_lossy()) - .collect::>() - .join(" "), + .map(|s| s.to_string_lossy().to_string()) + .collect::>(), }) .collect::>(); @@ -175,8 +174,13 @@ impl PickerDelegate for AttachModalDelegate { .map(|(id, candidate)| { StringMatchCandidate::new( id, - format!("{} {} {}", candidate.command, candidate.pid, candidate.name) - .as_str(), + format!( + "{} {} {}", + candidate.command.join(" "), + candidate.pid, + candidate.name + ) + .as_str(), ) }) .collect::>(), @@ -249,18 +253,40 @@ impl PickerDelegate for AttachModalDelegate { let candidate = &candidates.get(hit.candidate_id)?; Some( - ListItem::new(SharedString::from(format!("attach-modal-{ix}"))) + ListItem::new(SharedString::from(format!("process-entry-{ix}"))) .inset(true) .spacing(ListItemSpacing::Sparse) .toggle_state(selected) .child( v_flex() .items_start() - .child(Label::new(candidate.command.clone())) + .child(Label::new(format!("{} {}", candidate.name, candidate.pid))) .child( - Label::new(format!("Pid: {}, name: {}", candidate.pid, candidate.name)) - .size(LabelSize::Small) - .color(Color::Muted), + div() + .id(SharedString::from(format!("process-entry-{ix}-command"))) + .tooltip(Tooltip::text( + candidate + .command + .clone() + .into_iter() + .collect::>() + .join(" "), + )) + .child( + Label::new(format!( + "{} {}", + candidate.name, + candidate + .command + .clone() + .into_iter() + .skip(1) + .collect::>() + .join(" ") + )) + .size(LabelSize::Small) + .color(Color::Muted), + ), ), ), )