From 6bef4545f4fbda549e97d2c92eed22fd59d9612a Mon Sep 17 00:00:00 2001 From: Tad Hardesty Date: Sat, 5 Sep 2020 21:32:35 -0700 Subject: [PATCH] Compensate for VSC wanting unique variable names --- src/langserver/debugger/mod.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/langserver/debugger/mod.rs b/src/langserver/debugger/mod.rs index 9e6a8d59..78adf655 100644 --- a/src/langserver/debugger/mod.rs +++ b/src/langserver/debugger/mod.rs @@ -737,9 +737,17 @@ handle_request! { .. Default::default() }); + // If VSC receives two Variables with the same name, it only + // displays the first one. Avert this by adding suffixes. + let mut seen = std::collections::HashMap::new(); variables.extend(frame.locals.iter().enumerate().map(|(i, vt)| Variable { name: match locals.get(i) { - Some(local) => local.clone(), + Some(local) => { + match seen.entry(local).and_modify(|e| *e += 1).or_default() { + 0 => local.clone(), + n => format!("{} #{}", local, n), + } + } None => i.to_string(), }, value: vt.to_string(),