debugger: Fix nits (#30632)

Release Notes:

- N/A

---------

Co-authored-by: Anthony Eid <hello@anthonyeid.me>
This commit is contained in:
Remco Smits 2025-05-13 23:13:02 +02:00 committed by GitHub
parent f98c6fb2cf
commit 48b376fdc9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 15 deletions

View file

@ -577,6 +577,17 @@ impl DapStore {
let snapshot = buffer_handle.read(cx).snapshot();
let all_variables = session.read(cx).variables_by_stack_frame_id(stack_frame_id);
fn format_value(mut value: String) -> String {
const LIMIT: usize = 100;
if value.len() > LIMIT {
value.truncate(LIMIT);
value.push_str("...");
}
format!(": {}", value)
}
cx.spawn(async move |_, cx| {
let mut inlay_hints = Vec::with_capacity(inline_value_locations.len());
for inline_value_location in inline_value_locations.iter() {
@ -597,7 +608,7 @@ impl DapStore {
inlay_hints.push(InlayHint {
position,
label: InlayHintLabel::String(format!(": {}", variable.value)),
label: InlayHintLabel::String(format_value(variable.value.clone())),
kind: Some(InlayHintKind::Type),
padding_left: false,
padding_right: false,
@ -620,7 +631,7 @@ impl DapStore {
if let Some(response) = eval_task.await.log_err() {
inlay_hints.push(InlayHint {
position,
label: InlayHintLabel::String(format!(": {}", response.result)),
label: InlayHintLabel::String(format_value(response.result)),
kind: Some(InlayHintKind::Type),
padding_left: false,
padding_right: false,