Truncate multi-line debug value hints (#34305)

Release Notes:

- Multi-line debug inline values are now truncated.

Co-authored-by: Anthony Eid <hello@anthonyeid.me>
This commit is contained in:
Julia Ryan 2025-07-11 10:49:52 -07:00 committed by GitHub
parent 90bf602ceb
commit 0bd65829f7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 40 additions and 3 deletions

View file

@ -560,6 +560,11 @@ impl DapStore {
fn format_value(mut value: String) -> String {
const LIMIT: usize = 100;
if let Some(index) = value.find("\n") {
value.truncate(index);
value.push_str("");
}
if value.len() > LIMIT {
let mut index = LIMIT;
// If index isn't a char boundary truncate will cause a panic
@ -567,7 +572,7 @@ impl DapStore {
index -= 1;
}
value.truncate(index);
value.push_str("...");
value.push_str("");
}
format!(": {}", value)