debugger: Run build in terminal (#29645)

Currently contains the pre-work of making sessions creatable without a
definition, but still need to change the spawn in terminal
to use the running session

Release Notes:

- N/A

---------

Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
This commit is contained in:
Conrad Irwin 2025-05-05 21:08:14 +01:00 committed by GitHub
parent c12e6376b8
commit ff215b4f11
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 695 additions and 622 deletions

View file

@ -20,7 +20,8 @@ pub use debug_format::{
};
pub use task_template::{
DebugArgsRequest, HideStrategy, RevealStrategy, TaskTemplate, TaskTemplates,
substitute_all_template_variables_in_str,
substitute_all_template_variables_in_str, substitute_variables_in_map,
substitute_variables_in_str,
};
pub use vscode_debug_format::VsCodeDebugTaskFile;
pub use vscode_format::VsCodeTaskFile;

View file

@ -293,6 +293,28 @@ fn to_hex_hash(object: impl Serialize) -> anyhow::Result<String> {
Ok(hex::encode(hasher.finalize()))
}
pub fn substitute_variables_in_str(template_str: &str, context: &TaskContext) -> Option<String> {
let mut variable_names = HashMap::default();
let mut substituted_variables = HashSet::default();
let task_variables = context
.task_variables
.0
.iter()
.map(|(key, value)| {
let key_string = key.to_string();
if !variable_names.contains_key(&key_string) {
variable_names.insert(key_string.clone(), key.clone());
}
(key_string, value.as_str())
})
.collect::<HashMap<_, _>>();
substitute_all_template_variables_in_str(
template_str,
&task_variables,
&variable_names,
&mut substituted_variables,
)
}
pub fn substitute_all_template_variables_in_str<A: AsRef<str>>(
template_str: &str,
task_variables: &HashMap<String, A>,
@ -349,6 +371,31 @@ fn substitute_all_template_variables_in_vec(
Some(expanded)
}
pub fn substitute_variables_in_map(
keys_and_values: &HashMap<String, String>,
context: &TaskContext,
) -> Option<HashMap<String, String>> {
let mut variable_names = HashMap::default();
let mut substituted_variables = HashSet::default();
let task_variables = context
.task_variables
.0
.iter()
.map(|(key, value)| {
let key_string = key.to_string();
if !variable_names.contains_key(&key_string) {
variable_names.insert(key_string.clone(), key.clone());
}
(key_string, value.as_str())
})
.collect::<HashMap<_, _>>();
substitute_all_template_variables_in_map(
keys_and_values,
&task_variables,
&variable_names,
&mut substituted_variables,
)
}
fn substitute_all_template_variables_in_map(
keys_and_values: &HashMap<String, String>,
task_variables: &HashMap<String, &str>,