From 60df0cf7f0fc3876c26b1ceb967fd48c91ffe070 Mon Sep 17 00:00:00 2001 From: Margret Riegert Date: Wed, 12 Jun 2024 00:56:12 -0400 Subject: [PATCH] Sort local/static/global/sbvalue variables by name --- .gitignore | 1 + .../codelldb/src/debug_session/variables.rs | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 7d7af4aa..6206c45e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /build*/ /target/ *.pyc +/node_modules/ diff --git a/adapter/codelldb/src/debug_session/variables.rs b/adapter/codelldb/src/debug_session/variables.rs index b735c192..6db7107b 100644 --- a/adapter/codelldb/src/debug_session/variables.rs +++ b/adapter/codelldb/src/debug_session/variables.rs @@ -86,6 +86,9 @@ impl super::DebugSession { variable.name = "[return value]".to_owned(); variables.insert(0, variable); } + + variables.sort_by(|a, b| a.name.cmp(&b.name)); + variables } Container::Statics(frame) => { @@ -96,7 +99,11 @@ impl super::DebugSession { in_scope_only: true, }); let mut vars_iter = variables.iter().filter(|v| v.value_type() == ValueType::VariableStatic); - self.convert_scope_values(&mut vars_iter, "", Some(container_handle), false)? + let mut variables = self.convert_scope_values(&mut vars_iter, "", Some(container_handle), false)?; + + variables.sort_by(|a, b| a.name.cmp(&b.name)); + + variables } Container::Globals(frame) => { let variables = frame.variables(&VariableOptions { @@ -106,7 +113,11 @@ impl super::DebugSession { in_scope_only: true, }); let mut vars_iter = variables.iter().filter(|v| v.value_type() == ValueType::VariableGlobal); - self.convert_scope_values(&mut vars_iter, "", Some(container_handle), false)? + let mut variables = self.convert_scope_values(&mut vars_iter, "", Some(container_handle), false)?; + + variables.sort_by(|a, b| a.name.cmp(&b.name)); + + variables } Container::Registers(frame) => { let list = frame.registers(); @@ -132,6 +143,9 @@ impl super::DebugSession { }; variables.push(raw); } + + variables.sort_by(|a, b| a.name.cmp(&b.name)); + variables } Container::StackFrame(_) => vec![],