Skip to content

Visual Studio Code, rebuilt in Rust

Rust

feat(debug): list dynamic configuration providers' picks

rokarturaf759532708d
diff --git a/native/crates/app/src/workbench.rs b/native/crates/app/src/workbench.rs
index 47dc84df736..304ff8c9581 100644
--- a/native/crates/app/src/workbench.rs
+++ b/native/crates/app/src/workbench.rs
@@ -35,6 +35,7 @@ mod view_containers;
mod view_visibility;
mod debug_toolbar;
mod debug_visualizers;
+mod debug_dynamic;
pub(crate) mod debug_service;
pub(crate) mod debug_task_runner;
mod debug_view;
diff --git a/native/crates/app/src/workbench/debug_dynamic.rs b/native/crates/app/src/workbench/debug_dynamic.rs
new file mode 100644
index 00000000000..5b43373c966
--- /dev/null
+++ b/native/crates/app/src/workbench/debug_dynamic.rs
@@ -0,0 +1,243 @@
+//! debugConfigurationManager.ts dynamic configurations: the types whose provider registered with
+//! `DebugConfigurationProviderTriggerKind.Dynamic` or that an `onDebugDynamicConfigurations` activation event names,
+//! the picker of their configurations, and the recently used ones in workspace storage.
+
+use std::path::PathBuf;
+
+use gpui::{AsyncWindowContext, Context, WeakEntity, Window};
+use serde_json::{Value, json};
+
+use super::Workbench;
+use super::debug_service::{BUTTON_ANSWER, answer, on_workbench};
+use super::debug_task_runner::DebugTasks;
+use crate::quick_input::{Button, Entry, Item};
+
+/// debugStorage.ts `DEBUG_RECENT_DYNAMIC_CONFIGURATIONS`.
+const RECENT_KEY: &str = "debug.recentdynamicconfigurations";
+const ACTIVATION_EVENT: &str = "onDebugDynamicConfigurations";
+/// `DebugConfigurationProviderTriggerKind.Dynamic`.
+pub(super) const DYNAMIC: i64 = 2;
+
+/// A `getLaunches()` entry: a folder's launch.json, the `.code-workspace` file's `launch`, or the user settings'.
+#[derive(Clone, Debug, PartialEq)]
+pub(super) enum Launch {
+ Folder(PathBuf),
+ Workspace(PathBuf),
+ User,
+}
+
+impl Launch {
+ /// The folder `startDebugging` takes: `launch.workspace`, only a folder's launch has one.
+ pub(super) fn folder(&self) -> Option<PathBuf> {
+ match self {
+ Launch::Folder(folder) => Some(folder.clone()),
+ Launch::Workspace(_) | Launch::User => None,
+ }
+ }
+
+ /// `launch.name`.
+ fn name(&self) -> String {
+ match self {
+ Launch::Folder(folder) => folder.file_name().map(|name| name.to_string_lossy().into_owned()).unwrap_or_default(),
+ Launch::Workspace(_) => "workspace".into(),
+ Launch::User => "user settings".into(),
+ }
+ }
+}
+
+impl Workbench {
+ /// `getDynamicProviders`: each type with its debugger's label.
+ pub(super) fn dynamic_providers(&self) -> Vec<(String, String)> {
+ let mut types: Vec<String> = Vec::new();
+ for extension in &self.extensions {
+ let events = exthost::activation_events::read_activation_events(&extension.id, &extension.description);
+ let explicit: Vec<String> = events.iter().filter_map(|event| event.strip_prefix(ACTIVATION_EVENT)?.strip_prefix(':')).map(str::to_owned).collect();
+ if !explicit.is_empty() {
+ types.extend(explicit);
+ } else if events.iter().any(|event| event == ACTIVATION_EVENT)
+ && let Some(debug_type) = extension.description["contributes"]["debuggers"][0]["type"].as_str()
+ {
+ types.push(debug_type.to_owned());
+ }
+ }
+ types.extend(self.debug.providers.iter().filter(|provider| provider.trigger_kind == DYNAMIC).map(|provider| provider.debug_type.clone()));
+ let mut providers: Vec<(String, String)> = Vec::new();
+ for debug_type in types {
+ if providers.iter().any(|(known, _)| *known == debug_type) {
+ continue;
+ }
+ // `getDebuggerLabel(type)!`: a type no debugger contributes has no label to show.
+ let Some(debugger) = self.debug.debugger(&debug_type) else { continue };
+ let label = debugger.label().to_owned();
+ providers.push((debug_type, label));
+ }
+ providers
+ }
+
+ /// `getLaunches()`: the folders', the workspace file's in a workspace window, then the user settings'.
+ fn launches(&self) -> Vec<Launch> {
+ let mut launches: Vec<Launch> = self.workspace_folders().into_iter().map(Launch::Folder).collect();
+ if let Some(file) = self.workspace().and_then(|workspace| workspace.file.clone()) {
+ launches.push(Launch::Workspace(file));
+ }
+ launches.push(Launch::User);
+ launches
+ }
+
+ /// `getRecentDynamicConfigurations`: (name, type), the most recent first.
+ pub(super) fn recent_dynamic_configurations(&self) -> Vec<(String, String)> {
+ let stored = self.workspace_storage.lock().unwrap().get(RECENT_KEY).and_then(|raw| serde_json::from_str::<Value>(raw).ok()).unwrap_or_default();
+ let entries = stored.as_array().cloned().unwrap_or_default();
+ entries.iter().filter_map(|entry| Some((entry["name"].as_str()?.to_owned(), entry["type"].as_str()?.to_owned()))).collect()
+ }
+
+ fn store_recent_dynamic_configurations(&mut self, recent: &[(String, String)]) {
+ let stored = Value::Array(recent.iter().map(|(name, debug_type)| json!({ "name": name, "type": debug_type })).collect());
+ self.workspace_storage.lock().unwrap().set(RECENT_KEY, stored.to_string());
+ }
+
+ /// `removeRecentDynamicConfigurations`.
+ pub(super) fn remove_recent_dynamic_configuration(&mut self, name: &str, debug_type: &str) {
+ let mut recent = self.recent_dynamic_configurations();
+ recent.retain(|(known_name, known_type)| known_name != name || known_type != debug_type);
+ self.store_recent_dynamic_configurations(&recent);
+ }
+
+ /// `selectConfiguration(launch, name, config, { type })`: the name selected and put first in the recent list.
+ // shortcut: the selection keeps the name but not the type, so the Run and Debug dropdown and F5 fall back to launch.json's first configuration; upgrade with debugConfigurationManager.ts `selectedType`.
+ fn select_dynamic_configuration(&mut self, folder: Option<PathBuf>, name: String, debug_type: String) {
+ let mut recent = self.recent_dynamic_configurations();
+ recent.retain(|(known_name, known_type)| *known_name != name || *known_type != debug_type);
+ recent.insert(0, (name.clone(), debug_type));
+ self.store_recent_dynamic_configurations(&recent);
+ self.debug.selected = Some((folder, name));
+ self.store_selected_configuration();
+ }
+
+ /// debugQuickAccess.ts: a provider's `{label}...` pick, the provider's picker, then the chosen configuration
+ /// selected under the provider's type and started.
+ pub(super) fn pick_dynamic_and_start(&mut self, debug_type: String, window: &mut Window, cx: &mut Context<Self>) {
+ cx.spawn_in(window, async move |this, cx| {
+ let Ok(Some((folder, config))) = pick_dynamic_configuration(&this, cx, debug_type.clone()).await else { return };
+ let _ = on_workbench(&this, cx, |workbench, window, cx| {
+ let name = config["name"].as_str().unwrap_or_default().to_owned();
+ // The provider's type, not the config's: a config can have a subtype such as `node-terminal`.
+ workbench.select_dynamic_configuration(folder.clone(), name, debug_type);
+ drop(workbench.start_debugging(folder, config, json!({ "startedByUser": true }), DebugTasks::PreLaunch, window, cx));
+ });
+ })
+ .detach();
+ }
+
+ /// debugQuickAccess.ts: a recent dynamic configuration's pick, selected then started with the configuration
+ /// the type's provider gives the selected folder under that name (`selectedConfiguration.getConfig()`).
+ pub(super) fn start_recent_dynamic(&mut self, name: String, debug_type: String, window: &mut Window, cx: &mut Context<Self>) {
+ let (folder, _) = self.selected_launch();
+ self.select_dynamic_configuration(folder.clone(), name.clone(), debug_type.clone());
+ let launches: Vec<Launch> = folder.clone().map(Launch::Folder).into_iter().collect();
+ cx.spawn_in(window, async move |this, cx| {
+ let configurations = match provide_dynamic_configurations(&this, cx, &debug_type, launches).await {
+ Ok(configurations) => configurations,
+ Err(message) => return drop(on_workbench(&this, cx, |workbench, _, _| workbench.notify_error(message))),
+ };
+ let config = configurations.into_iter().map(|(_, config)| config).find(|config| config["name"].as_str() == Some(&name));
+ let _ = on_workbench(&this, cx, |workbench, window, cx| drop(workbench.start_debugging(folder, config.unwrap_or(Value::Null), json!({ "startedByUser": true }), DebugTasks::PreLaunch, window, cx)));
+ })
+ .detach();
+ }
+}
+
+/// `provider.pick()`: the type's configurations of each launch in "Select Launch Configuration", answered with the
+/// launch's folder; a pick's gear writes it to its launch and selects it there instead.
+pub(super) async fn pick_dynamic_configuration(this: &WeakEntity<Workbench>, cx: &mut AsyncWindowContext, debug_type: String) -> Result<Option<(Option<PathBuf>, Value)>, String> {
+ let configurations = dynamic_configurations(this, cx, &debug_type).await?;
+ let mut entries = Vec::new();
+ for (handle, (launch, config)) in configurations.iter().enumerate() {
+ let button = Button { handle: 0, codicon: Some("gear".into()), tooltip: Some("Edit Debug Configuration in launch.json".into()), ..Button::default() };
+ let label = config["name"].as_str().unwrap_or_default().to_owned();
+ entries.push(Entry::Item(Item { handle: handle as i64, label, description: Some(launch.name()), pickable: true, buttons: vec![button], ..Item::default() }));
+ }
+ let picked = on_workbench(this, cx, |workbench, window, cx| workbench.debug_pick("Select Launch Configuration", entries, window, cx))?;
+ let Some(picked) = picked.await.ok().flatten() else { return Ok(None) };
+ if let Some(button) = picked.strip_prefix(BUTTON_ANSWER) {
+ let (launch, config) = configurations[button.parse::<usize>().expect("an item handle")].clone();
+ on_workbench(this, cx, |workbench, window, cx| workbench.write_dynamic_configuration(launch, &debug_type, config, window, cx))?;
+ return Ok(None);
+ }
+ let (launch, config) = configurations[picked.parse::<usize>().expect("an item handle")].clone();
+ Ok(Some((launch.folder(), config)))
+}
+
+/// `getDynamicConfigurationsByType`: each launch's configurations from the type's dynamic provider.
+pub(super) async fn dynamic_configurations(this: &WeakEntity<Workbench>, cx: &mut AsyncWindowContext, debug_type: &str) -> Result<Vec<(Launch, Value)>, String> {
+ let launches = on_workbench(this, cx, |workbench, _, _| workbench.launches())?;
+ provide_dynamic_configurations(this, cx, debug_type, launches).await
+}
+
+/// `provideDebugConfigurations` of the type's dynamic provider for each launch, after its `onDebugDynamicConfigurations`
+/// activation.
+async fn provide_dynamic_configurations(this: &WeakEntity<Workbench>, cx: &mut AsyncWindowContext, debug_type: &str, launches: Vec<Launch>) -> Result<Vec<(Launch, Value)>, String> {
+ let events = on_workbench(this, cx, |workbench, _, _| {
+ workbench.debug.init_extension_activations();
+ [ACTIVATION_EVENT.to_owned(), "onDebug".to_owned(), format!("{ACTIVATION_EVENT}:{debug_type}")].map(|event| workbench.host.activate_by_event(&event))
+ })?;
+ for event in events {
+ let _ = event.await;
+ }
+ let handle = on_workbench(this, cx, |workbench, _, _| {
+ let provider = workbench.debug.providers.iter().find(|provider| provider.debug_type == debug_type && provider.trigger_kind == DYNAMIC && provider.has_provide);
+ provider.map(|provider| provider.handle)
+ })?;
+ let Some(handle) = handle else { return Ok(Vec::new()) };
+ let mut configurations = Vec::new();
+ for launch in launches {
+ let uri = launch.folder().map_or(Value::Null, |folder| exthost::scan::file_uri(&folder));
+ let reply = on_workbench(this, cx, |workbench, _, _| workbench.host.call("ExtHostDebugService", "$provideDebugConfigurations", vec![json!(handle), uri]))?;
+ let provided = answer(reply).await?;
+ configurations.extend(provided.as_array().into_iter().flatten().map(|config| (launch.clone(), config.clone())));
+ }
+ Ok(configurations)
+}
+
+impl Workbench {
+ /// The picker's gear: `launch.openConfigFile`, `writeConfiguration`, then the written configuration selected by
+ /// name and dropped from the recent list.
+ fn write_dynamic_configuration(&mut self, launch: Launch, debug_type: &str, config: Value, window: &mut Window, cx: &mut Context<Self>) {
+ let outcome = match &launch {
+ Launch::Folder(folder) => self.open_folder_launch_json(folder, window, cx),
+ Launch::Workspace(file) => {
+ self.open_file(file.clone(), true, window, cx);
+ crate::commands::Outcome::done()
+ }
+ Launch::User => self.execute_command("workbench.action.openSettingsJson", vec![json!({ "revealSetting": { "key": "launch" } })], window, cx),
+ };
+ super::quick_access::show_failure("Edit Debug Configuration in launch.json".into(), outcome, window, cx);
+ let name = config["name"].as_str().unwrap_or_default().to_owned();
+ let folder = launch.folder();
+ let overrides = config::configuration::Overrides { resource: folder.as_deref(), override_identifier: None };
+ let mut settings = self.settings.lock().unwrap();
+ let inspected = settings.configuration.inspect("launch", &overrides);
+ let (target, layer) = match &launch {
+ Launch::Folder(_) => (config::service::Target::WorkspaceFolder, inspected.workspace_folder),
+ Launch::Workspace(_) => (config::service::Target::Workspace, inspected.workspace),
+ Launch::User => (config::service::Target::User, inspected.user_local),
+ };
+ let mut launch_value = layer.value.unwrap_or_else(|| json!({}));
+ let mut configurations = launch_value["configurations"].as_array().cloned().unwrap_or_default();
+ configurations.push(config);
+ launch_value["configurations"] = Value::Array(configurations);
+ let written = settings.update_value("launch", Some(&launch_value), target, folder.as_deref(), &[]);
+ if let Ok(change) = &written
+ && !change.is_empty()
+ {
+ self.host.send_configuration_change(&settings, change);
+ }
+ drop(settings);
+ if let Err(error) = written {
+ return self.notify_error(error);
+ }
+ self.debug.selected = Some((folder, name.clone()));
+ self.store_selected_configuration();
+ self.remove_recent_dynamic_configuration(&name, debug_type);
+ }
+}
diff --git a/native/crates/app/src/workbench/debug_service.rs b/native/crates/app/src/workbench/debug_service.rs
index 94a4b592f8f..951c2a1bfd0 100644
--- a/native/crates/app/src/workbench/debug_service.rs
+++ b/native/crates/app/src/workbench/debug_service.rs
@@ -35,12 +35,17 @@ enum Debuggee {
const CHOSEN_ENVIRONMENTS_KEY: &str = "debug.chosenenvironment";
const SELECTED_CONFIG_KEY: &str = "debug.selectedconfigname";
const SELECTED_ROOT_KEY: &str = "debug.selectedroot";
+/// `debug_pick`'s answer for an item's button: this prefix, then the item's handle.
+pub(super) const BUTTON_ANSWER: &str = "button:";
/// A `$registerDebugConfigurationProvider` registration.
#[derive(Clone, Debug)]
pub struct ConfigurationProvider {
pub handle: i64,
pub debug_type: String,
+ /// `DebugConfigurationProviderTriggerKind`: 1 initial, 2 dynamic.
+ pub trigger_kind: i64,
+ pub has_provide: bool,
pub has_resolve: bool,
pub has_resolve2: bool,
}
@@ -106,7 +111,7 @@ pub struct DebugService {
impl DebugService {
/// debugAdapterManager.ts `initExtensionActivationsIfNeeded`, run before the first debugger activation.
- fn init_extension_activations(&mut self) {
+ pub(super) fn init_extension_activations(&mut self) {
if self.early_activated.is_none() {
self.early_activated = Some(self.debuggers.iter().map(|debugger| debugger.extension_id.clone()).filter(|id| crate::perf::activation(id).is_some()).collect());
}
@@ -249,6 +254,8 @@ impl Workbench {
"$acceptDAExit" => self.adapter_exited(arg(0).as_u64().unwrap_or_default() as u32, None, window, cx),
"$registerDebugConfigurationProvider" => self.debug.providers.push(ConfigurationProvider {
debug_type: arg(0).as_str().unwrap_or_default().to_owned(),
+ trigger_kind: arg(1).as_i64().unwrap_or_default(),
+ has_provide: arg(2) == true,
has_resolve: arg(3) == true,
has_resolve2: arg(4) == true,
handle: arg(5).as_i64().unwrap_or_default(),
@@ -1446,6 +1453,14 @@ impl Workbench {
}
self.hide_quick_input_by_id(id, window, cx);
}
+ Event::TriggerItemButton(handle, _, _) => {
+ if let Some(Owner::Debug(reply)) = self.quick_inputs.owner_mut(id)
+ && let Some(reply) = reply.take()
+ {
+ let _ = reply.send(Some(format!("{BUTTON_ANSWER}{handle}")));
+ }
+ self.hide_quick_input_by_id(id, window, cx);
+ }
Event::Hide => {
if let Some(Owner::Debug(reply)) = self.quick_inputs.owner_mut(id)
&& let Some(reply) = reply.take()
@@ -1609,9 +1624,14 @@ async fn create_session(this: &WeakEntity<Workbench>, cx: &mut AsyncWindowContex
}
let unresolved = config.clone();
let mut debug_type = config["type"].as_str().map(str::to_owned);
+ let mut folder = folder;
if debug_type.is_none() {
- let Some(guessed) = guess_debugger(this, cx).await? else { return Ok(false) };
+ let Some((guessed, with_config)) = guess_debugger(this, cx).await? else { return Ok(false) };
debug_type = Some(guessed);
+ if let Some((dynamic_folder, dynamic_config)) = with_config {
+ folder = dynamic_folder;
+ config.as_object_mut().expect("a config object").extend(dynamic_config.as_object().cloned().unwrap_or_default());
+ }
}
let folder_uri = folder.as_deref().map(exthost::scan::file_uri);
let resolved = resolve_by_providers(this, cx, folder_uri.clone(), debug_type.clone().unwrap_or_default(), config).await?;
@@ -1629,13 +1649,20 @@ async fn create_session(this: &WeakEntity<Workbench>, cx: &mut AsyncWindowContex
}
/// debugAdapterManager.ts `guessDebugger`: the debuggers interested in the active editor's language, picked when
-/// more than one; remembered per file in `chosenEnvironments`.
-async fn guess_debugger(this: &WeakEntity<Workbench>, cx: &mut AsyncWindowContext) -> Result<Option<String>, String> {
+/// more than one; remembered per file in `chosenEnvironments`. A "More {0} options..." pick also answers the
+/// dynamic configuration picked and its folder.
+async fn guess_debugger(this: &WeakEntity<Workbench>, cx: &mut AsyncWindowContext) -> Result<Option<(String, Option<(Option<PathBuf>, Value)>)>, String> {
let (resource, language) = on_workbench(this, cx, |workbench, _, _| workbench.editors.active().map(|editor| (editor.document().uri_string(), editor.document().language_id.clone())).unzip())?;
if let Some(resource) = &resource
- && let Some(chosen) = on_workbench(this, cx, |workbench, _, _| workbench.debug.chosen_environments.get(resource).and_then(|chosen| chosen["type"].as_str()).map(str::to_owned))?
+ && let Some(chosen) = on_workbench(this, cx, |workbench, _, _| workbench.debug.chosen_environments.get(resource).cloned())?
+ && let Some(debug_type) = chosen["type"].as_str()
{
- return Ok(Some(chosen));
+ let mut with_config = None;
+ if let Some(label) = chosen["dynamicLabel"].as_str() {
+ let configurations = super::debug_dynamic::dynamic_configurations(this, cx, debug_type).await?;
+ with_config = configurations.into_iter().find(|(_, config)| config["name"].as_str() == Some(label)).map(|(launch, config)| (launch.folder(), config));
+ }
+ return Ok(Some((debug_type.to_owned(), with_config)));
}
let activation = on_workbench(this, cx, |workbench, _, _| {
workbench.debug.init_extension_activations();
@@ -1643,7 +1670,8 @@ async fn guess_debugger(this: &WeakEntity<Workbench>, cx: &mut AsyncWindowContex
})?;
let _ = activation.0.await;
let _ = activation.1.await;
- let (candidates, contributed, by_language, language_label) = on_workbench(this, cx, |workbench, window, _| {
+ let (candidates, contributed, by_language, language_label, dynamic) = on_workbench(this, cx, |workbench, window, _| {
+ let dynamic = workbench.dynamic_providers();
let context = workbench.key_context(window);
let mut contributed = Vec::new();
for action in crate::menus::menu_actions(&workbench.menus, crate::menus::MenuId::DebugCreateConfiguration, &context) {
@@ -1656,8 +1684,8 @@ async fn guess_debugger(this: &WeakEntity<Workbench>, cx: &mut AsyncWindowContex
let enabled: Vec<&Debugger> = workbench.debug.debuggers.iter().filter(|debugger| holds(debugger.when()) && workbench.debug.adapter_types.contains(&debugger.debug_type)).collect();
let interested: Vec<&Debugger> = enabled.iter().copied().filter(|debugger| language.as_deref().is_some_and(|language| debugger.interested_in_language(language))).collect();
let mut candidates: Vec<&Debugger> = match interested.len() {
- 1 => return (vec![(interested[0].debug_type.clone(), interested[0].label().to_owned(), false)], contributed, true, language_label),
- 0 => enabled.into_iter().filter(|debugger| debugger.has_initial_configuration() || workbench.debug.providers.iter().any(|provider| provider.debug_type == debugger.debug_type)).collect(),
+ 1 => return (vec![(interested[0].debug_type.clone(), interested[0].label().to_owned(), false)], contributed, true, language_label, dynamic),
+ 0 => enabled.into_iter().filter(|debugger| debugger.has_initial_configuration() || workbench.debug.providers.iter().any(|provider| provider.debug_type == debugger.debug_type && provider.has_provide)).collect(),
_ => interested,
};
candidates.retain(|debugger| !debugger.hidden_when().and_then(crate::contextkey::Expr::deserialize).is_some_and(|when| when.evaluate(&context)));
@@ -1668,10 +1696,10 @@ async fn guess_debugger(this: &WeakEntity<Workbench>, cx: &mut AsyncWindowContex
let suggested = early_activated.contains(&debugger.extension_id) || workbench.debug.used_debug_types.contains(&debugger.debug_type);
(debugger.debug_type.clone(), debugger.label().to_owned(), suggested)
});
- (candidates.collect(), contributed, false, language_label)
+ (candidates.collect(), contributed, false, language_label, dynamic)
})?;
if by_language {
- return remember_chosen_environment(this, cx, resource, candidates[0].0.clone());
+ return remember_chosen_environment(this, cx, resource, candidates[0].0.clone(), None);
}
if candidates.is_empty()
&& let Some(label) = language_label
@@ -1683,11 +1711,15 @@ async fn guess_debugger(this: &WeakEntity<Workbench>, cx: &mut AsyncWindowContex
}
return Ok(None);
}
- let (entries, picks) = select_debugger_picks(&candidates, &contributed, language_label.as_deref());
+ let (entries, picks) = select_debugger_picks(&candidates, &dynamic, &contributed, language_label.as_deref());
let picked = on_workbench(this, cx, |workbench, window, cx| workbench.debug_pick("Select debugger", entries, window, cx))?;
let Some(handle) = picked.await.ok().flatten().and_then(|handle| handle.parse::<usize>().ok()) else { return Ok(None) };
let debug_type = match &picks[handle] {
GuessPick::Debugger(debug_type) => debug_type.clone(),
+ GuessPick::Dynamic(debug_type) => {
+ let Some(picked) = super::debug_dynamic::pick_dynamic_configuration(this, cx, debug_type.clone()).await? else { return Ok(None) };
+ return remember_chosen_environment(this, cx, resource, debug_type.clone(), Some(picked));
+ }
// debugAdapterManager.ts: a `MenuId.DebugCreateConfiguration` item runs its command and starts nothing.
GuessPick::Command(command) => {
on_workbench(this, cx, |workbench, window, cx| drop(workbench.execute_command(command, Vec::new(), window, cx)))?;
@@ -1699,19 +1731,21 @@ async fn guess_debugger(this: &WeakEntity<Workbench>, cx: &mut AsyncWindowContex
return Ok(None);
}
};
- remember_chosen_environment(this, cx, resource, debug_type)
+ remember_chosen_environment(this, cx, resource, debug_type, None)
}
enum GuessPick {
Debugger(String),
+ /// A dynamic configuration provider's type.
+ Dynamic(String),
Install,
Command(String),
}
-/// debugAdapterManager.ts `guessDebugger`'s picks: the Suggested debuggers, the others, Install, then the
-/// `MenuId.DebugCreateConfiguration` items; each item's handle is its index in the returned picks.
-// shortcut: no "More {0} options..." picks, the port has no dynamic configuration providers yet.
-fn select_debugger_picks(candidates: &[(String, String, bool)], contributed: &[(String, String)], language_label: Option<&str>) -> (Vec<Entry>, Vec<GuessPick>) {
+/// debugAdapterManager.ts `guessDebugger`'s picks: the Suggested debuggers, the others, the dynamic providers'
+/// "More {0} options...", Install, then the `MenuId.DebugCreateConfiguration` items; each item's handle is its index
+/// in the returned picks.
+fn select_debugger_picks(candidates: &[(String, String, bool)], dynamic: &[(String, String)], contributed: &[(String, String)], language_label: Option<&str>) -> (Vec<Entry>, Vec<GuessPick>) {
let mut entries = Vec::new();
let mut picks = Vec::new();
let mut push = |entries: &mut Vec<Entry>, label: String, pick: GuessPick| {
@@ -1733,6 +1767,14 @@ fn select_debugger_picks(candidates: &[(String, String, bool)], contributed: &[(
push(&mut entries, label.clone(), GuessPick::Debugger(debug_type.clone()));
}
}
+ if !dynamic.is_empty() {
+ if !entries.is_empty() {
+ entries.push(Entry::Separator(None));
+ }
+ for (debug_type, label) in dynamic {
+ push(&mut entries, format!("More {label} options..."), GuessPick::Dynamic(debug_type.clone()));
+ }
+ }
entries.push(Entry::Separator(None));
let install = match language_label {
Some(label) => format!("Install an extension for {label}..."),
@@ -1745,16 +1787,21 @@ fn select_debugger_picks(candidates: &[(String, String, bool)], contributed: &[(
(entries, picks)
}
-/// debugService.ts `startDebugging`: the debugger guessed for a file is remembered for it (`chosenEnvironments`).
-fn remember_chosen_environment(this: &WeakEntity<Workbench>, cx: &mut AsyncWindowContext, resource: Option<String>, debug_type: String) -> Result<Option<String>, String> {
+/// debugService.ts `startDebugging`: the debugger guessed for a file is remembered for it (`chosenEnvironments`),
+/// with the dynamic configuration's name as `dynamicLabel`.
+fn remember_chosen_environment(this: &WeakEntity<Workbench>, cx: &mut AsyncWindowContext, resource: Option<String>, debug_type: String, with_config: Option<(Option<PathBuf>, Value)>) -> Result<Option<(String, Option<(Option<PathBuf>, Value)>)>, String> {
if let Some(resource) = resource {
+ let mut chosen = json!({ "type": debug_type });
+ if let Some((_, config)) = &with_config {
+ chosen["dynamicLabel"] = config["name"].clone();
+ }
on_workbench(this, cx, |workbench, _, _| {
- workbench.debug.chosen_environments.insert(resource, json!({ "type": debug_type }));
+ workbench.debug.chosen_environments.insert(resource, chosen);
let stored = Value::Object(workbench.debug.chosen_environments.clone()).to_string();
workbench.workspace_storage.lock().unwrap().set(CHOSEN_ENVIRONMENTS_KEY, stored);
})?;
}
- Ok(Some(debug_type))
+ Ok(Some((debug_type, with_config)))
}
/// debugConfigurationManager.ts `resolveConfigurationByProviders`: the type's providers then `*`'s, again while
@@ -2072,19 +2119,21 @@ mod tests {
}).collect()
}
- /// debugAdapterManager.ts `guessDebugger`: the Suggested section, an unlabelled one for the others, then Install
- /// and the `DebugCreateConfiguration` items after a separator.
+ /// debugAdapterManager.ts `guessDebugger`: the Suggested section, an unlabelled one for the others, one for the
+ /// dynamic providers, then Install and the `DebugCreateConfiguration` items after a separator.
#[test]
fn the_select_debugger_picks_group_the_suggested_debuggers() {
let candidates = [("node".to_owned(), "Node.js".to_owned(), true), ("chrome".to_owned(), "Web App (Chrome)".to_owned(), false)];
let contributed = [("x.create".to_owned(), "Create X Configuration".to_owned())];
- let (entries, picks) = select_debugger_picks(&candidates, &contributed, Some("JavaScript"));
- assert_eq!(rows(&entries), ["--Suggested--", "0:Node.js", "----", "1:Web App (Chrome)", "----", "2:Install an extension for JavaScript...", "3:Create X Configuration"]);
+ let dynamic = [("node".to_owned(), "Node.js".to_owned())];
+ let (entries, picks) = select_debugger_picks(&candidates, &dynamic, &contributed, Some("JavaScript"));
+ assert_eq!(rows(&entries), ["--Suggested--", "0:Node.js", "----", "1:Web App (Chrome)", "----", "2:More Node.js options...", "----", "3:Install an extension for JavaScript...", "4:Create X Configuration"]);
assert!(matches!(&picks[1], GuessPick::Debugger(debug_type) if debug_type == "chrome"));
- assert!(matches!(picks[2], GuessPick::Install));
- assert!(matches!(&picks[3], GuessPick::Command(command) if command == "x.create"));
+ assert!(matches!(&picks[2], GuessPick::Dynamic(debug_type) if debug_type == "node"));
+ assert!(matches!(picks[3], GuessPick::Install));
+ assert!(matches!(&picks[4], GuessPick::Command(command) if command == "x.create"));
- let (entries, _) = select_debugger_picks(&candidates[1..], &[], None);
+ let (entries, _) = select_debugger_picks(&candidates[1..], &[], &[], None);
assert_eq!(rows(&entries), ["0:Web App (Chrome)", "----", "1:Install extension..."]);
}
diff --git a/native/crates/app/src/workbench/quick_access/start_debug.rs b/native/crates/app/src/workbench/quick_access/start_debug.rs
index e613feeff75..cc03b4246d4 100644
--- a/native/crates/app/src/workbench/quick_access/start_debug.rs
+++ b/native/crates/app/src/workbench/quick_access/start_debug.rs
@@ -23,6 +23,10 @@ pub enum DebugPick {
/// A launch configuration of the folder, started on accept; its gear button opens the folder's launch.json.
Launch { folder: PathBuf, name: String },
AddConfiguration(PathBuf),
+ /// A recently used dynamic configuration; its trash button drops it from the recent list.
+ RecentDynamic { name: String, debug_type: String },
+ /// A dynamic configuration provider's `{label}...`, its type's picker on accept.
+ Dynamic(String),
}
impl Workbench {
@@ -85,6 +89,21 @@ impl Workbench {
accepts.insert(0, accept);
}
+ let dynamic = self.dynamic_providers();
+ if !dynamic.is_empty() {
+ entries.push(Entry::Separator(Some("contributed".into())));
+ }
+ for (name, debug_type) in self.recent_dynamic_configurations() {
+ let Some(label_highlights) = matches_fuzzy_separate(filter, &name) else { continue };
+ let button = Button { handle: 0, codicon: Some("trash".into()), tooltip: Some("Remove Launch Configuration".into()), ..Button::default() };
+ entries.push(Entry::Item(Item { handle: 0, label: name.clone(), label_highlights, pickable: true, buttons: vec![button], ..Item::default() }));
+ accepts.push(Accept::Debug(DebugPick::RecentDynamic { name, debug_type }));
+ }
+ for (debug_type, label) in dynamic {
+ entries.push(Entry::Item(Item { handle: 0, label: format!("$(folder) {label}..."), pickable: true, ..Item::default() }));
+ accepts.push(Accept::Debug(DebugPick::Dynamic(debug_type)));
+ }
+
if !folders.is_empty() {
entries.push(Entry::Separator(Some("configure".into())));
}
@@ -121,13 +140,21 @@ impl Workbench {
let outcome = self.open_folder_launch_json(&folder, window, cx);
super::show_failure("Add Configuration...".into(), outcome, window, cx);
}
+ DebugPick::RecentDynamic { name, debug_type } => self.start_recent_dynamic(name, debug_type, window, cx),
+ DebugPick::Dynamic(debug_type) => self.pick_dynamic_and_start(debug_type, window, cx),
}
}
- /// The gear button's `trigger`: `launch.openConfigFile`, then `TriggerAction.CLOSE_PICKER`.
+ /// A button's `trigger`, then `TriggerAction.CLOSE_PICKER`: the gear runs `launch.openConfigFile`, the trash
+ /// `removeRecentDynamicConfigurations`.
pub(super) fn trigger_debug_pick(&mut self, pick: DebugPick, window: &mut Window, cx: &mut Context<Self>) {
- let DebugPick::Launch { folder, .. } = pick else { return };
- let outcome = self.open_folder_launch_json(&folder, window, cx);
- super::show_failure("Configure Launch Configuration".into(), outcome, window, cx);
+ match pick {
+ DebugPick::Launch { folder, .. } => {
+ let outcome = self.open_folder_launch_json(&folder, window, cx);
+ super::show_failure("Configure Launch Configuration".into(), outcome, window, cx);
+ }
+ DebugPick::RecentDynamic { name, debug_type } => self.remove_recent_dynamic_configuration(&name, &debug_type),
+ DebugPick::AddConfiguration(_) | DebugPick::Dynamic(_) => {}
+ }
}
}
diff --git a/native/crates/app/src/workbench/quick_access/tests.rs b/native/crates/app/src/workbench/quick_access/tests.rs
index 2e7fc2734fc..80eefd5dfdf 100644
--- a/native/crates/app/src/workbench/quick_access/tests.rs
+++ b/native/crates/app/src/workbench/quick_access/tests.rs
@@ -308,7 +308,10 @@ fn the_debug_picker_lists_and_starts_the_launch_configurations(cx: &mut TestAppC
let (workbench, cx) = cx.add_window_view(|_, cx| {
let mut workbench = Workbench::new(theme, app_root.clone(), Some(workspace), Languages::new(&[]), settings, HostSync::new(std::sync::mpsc::channel().0), cx);
workbench.load_keybindings(crate::keybindings::default_keybindings(&[]), dir.join("User/keybindings.json"));
- workbench.debug.debuggers.push(crate::debug::configuration::Debugger { debug_type: "node".into(), contribution: json!({}), extension_id: "a.node".into() });
+ workbench.debug.debuggers.push(crate::debug::configuration::Debugger { debug_type: "node".into(), contribution: json!({ "label": "Node.js" }), extension_id: "a.node".into() });
+ let provider = crate::workbench::debug_service::ConfigurationProvider { handle: 1, debug_type: "node".into(), trigger_kind: 2, has_provide: true, has_resolve: false, has_resolve2: false };
+ workbench.debug.providers.push(provider);
+ workbench.workspace_storage.lock().unwrap().set("debug.recentdynamicconfigurations", json!([{ "name": "Run Script: test", "type": "node" }]).to_string());
workbench.debug.selected = Some((Some(folder.clone()), "Launch app.js".into()));
workbench
});
@@ -316,9 +319,9 @@ fn the_debug_picker_lists_and_starts_the_launch_configurations(cx: &mut TestAppC
workbench.update_in(cx, |workbench, window, cx| drop(workbench.execute_command("workbench.action.debug.selectandstart", Vec::new(), window, cx)));
assert_eq!(workbench.read_with(cx, |workbench, _| workbench.quick_inputs.current().unwrap().placeholder.clone()).as_deref(), Some("Type the name of a launch configuration to run."));
- assert_eq!(workbench.read_with(cx, labels), ["--Most Recent--Launch app.js", "----Grouped", "----Launch lazy.js", "--configure--Add Configuration..."]);
+ assert_eq!(workbench.read_with(cx, labels), ["--Most Recent--Launch app.js", "----Grouped", "----Launch lazy.js", "--contributed--Run Script: test", "$(folder) Node.js...", "--configure--Add Configuration..."]);
cx.simulate_input("lazy");
- assert_eq!(workbench.read_with(cx, labels), ["--launch.json--Launch lazy.js", "--configure--Add Configuration..."]);
+ assert_eq!(workbench.read_with(cx, labels), ["--launch.json--Launch lazy.js", "--contributed--$(folder) Node.js...", "--configure--Add Configuration..."]);
cx.simulate_keystrokes("enter");
cx.run_until_parked();
assert_eq!(workbench.read_with(cx, |workbench, _| (workbench.quick_inputs.current().is_none(), workbench.debug.selected.clone())), (true, Some((Some(folder.clone()), "Launch lazy.js".into()))), "the pick is selected and started");
diff --git a/port/ledger.md b/port/ledger.md
index d4e4ec7c0fb..289927f2566 100644
--- a/port/ledger.md
+++ b/port/ledger.md
@@ -530,7 +530,7 @@ One row per upstream unit, generated by `bun port/tools/gen-ledger.ts`; mileston
| workbench/contrib/commands | workbench contribution | M9 | verified | | runCommands (commands.rs register_run_commands): cargo test -p app commands::, argument checks, spread args, order, stop at a failure; argument errors and the failure notify (cargo test -p app run_commands_argument_errors_notify) |
| workbench/contrib/comments | workbench contribution | M13 | verified | | workbench/comments_view.rs, workbench/comment_thread_widget.rs, comment_thread_floating.rs, workbench/comment_thread_floating_layout.rs, workbench/comment_node.rs, workbench/commenting_ranges.rs, workbench/comment_navigation.rs, workbench/editor_view/comment_glyph.rs, multi_diff_editor_view.rs: cargo test -p app comment diff floating room multi_diff comment_thread_floating two_threads_keep_their_reply_forms_open_together a_wrapped_comment_body_grows_its_zone the_reached_thread_takes_the_focus a_markdown_comment_previews_its_first_rendered_block the_filter_keeps_its_history_and_escape_clears_it the_thread_menu_replies_to_the_thread a_comment_s_code_span_draws_no_code_block_background additional_actions_show_under_the_body_and_run_with_the_thread a_commenting_range_is_reached_at_its_columns_unless_it_holds_the_cursor dismissing_a_new_template_keeps_it_open an_expanded_thread_shows_a_zone_and_replies_run_the_form_actions a_comment_switched_to_editing_runs_the_edit_actions rows_sit_in_the_pane_s_inset_with_the_tree_s_indent_and_guides (commentThreadFloatingWidget.test.ts); ui-pair `portComments.openDiff` (modified, original, multi, floating), steps-comment-floating.json, steps-comment-additional.json, steps-comment-escape-typed.json, steps-comment-reply-editor.json, steps-comments.json (port/results/language-features.md Comments, Comment editing and commands, Floating comment threads); cargo test -p app reactions_are_action_items_4px_apart |
| workbench/contrib/customEditor | workbench contribution | M17 | ported | [3 L] custom_editors.rs: a diff always opens in the text diff editor, where customEditors.ts `createDiffEditorInput` opens a diff of resources matching an editor's selector (`workbench.diffEditorAssociations`, `priority.diffEditor`) as a `CustomEditorDiffInput` (customEditorDiffInput.ts, inline) or a `DiffEditorInput` of two `CustomEditorSideBySideDiffInput`s or `CustomEditorInput`s, with the proposed `customEditorDiffs` capabilities (`supportsInlineDiff`, `supportsSideBySideDiff`, used by markdown-language-features' preview); so `activeCustomEditorTextDiff` (contextkeys.ts) is never set and Reopen as Text (editor.contribution.ts `ReOpenInTextEditorAction`, `enableInModalMode`) is missing from the editor title and the modal header | cargo test -p app custom_editors each_group_s_custom_text_editor_has_its_own_webview a_custom_text_editor_s_navigation_drives_the_outline a_custom_document_open_in_another_group_moves_to_the_active_one a_custom_document_with_multiple_editors_opens_one_more_in_the_active_group a_workspace_association_wins_over_a_user_one_of_the_same_length a_reopened_preview_keeps_its_tab_position two_default_editors_for_a_resource_ask_once_which_to_keep markdown_editor_files_offer; `FIXTURE=custom-editor-tests port/tools/webview-check` 8/8 |
-| workbench/contrib/debug | workbench contribution | M16 | ported | [3 M] variable_menu.rs: no View Binary Data: debug.contribution.ts registers it only in the rows' `inline` group, and the port's Variables, Watch and hover rows have no inline action bar, no `vscode-debug-memory` file system and no hex editor install prompt (variablesView.ts `VIEW_MEMORY_ID`) <br> [3 M] debug_visualizers.rs: visualized rows draw only in the Variables view; the Watch view's and the debug hover's expression children keep their plain rows (watchExpressionsView.ts:98, debugHover.ts:142 register `VisualizedVariableRenderer`) <br> [3 S] debug_service.rs: `guess_debugger`'s Select Debugger picker has no "More {0} options..." picks of the dynamic configuration providers (debugAdapterManager.ts `getDynamicProviders`), which the port does not have <br> [3 S] debugQuickAccess.ts: the picker has no dynamic configuration providers' `{label}...` picks with the `contributed` description, where the reference lists `Node.js...` (ui-pair `debug/quick-access.json`, `FOLDER=port/fixtures/debug-node`) <br> [3 M] debug_editor: no inline breakpoint widgets: neither the candidate dots (breakpointEditorContribution.ts `requestBreakpointCandidateLocations`, `breakpointLocations` request on the breakpoints' lines) nor the `InlineBreakpointWidget` of a column breakpoint (ui-pair `debug/variables-menu.json`, line 5 of app.js) | cargo test -p app debug launch_picker_shrinks the_debug_container_more_actions debug_service a_workbench_hover_draws_over_the_debug_hover the_tree_height_keeps_an_above_hover_off_the_hovered_line watch_expression_labels_use_the_monospace_font debug_view debug_task_runner debug_commands debug_console debug::ansi an_ended_session_stays_in_the_picker_until_cleared_or_started_again a_start_or_restart_saves_the_dirty_editors a_hit_breakpoint_enables_its_dependents debug_inline_values debug_hover alt_click_toggles_the_loaded_subtree a_click_on_a_hover_row_focuses_the_tree a_lazy_row_takes_its_value_from_the_eye_button the_find_widget_filters_the_hover_tree disassembly list_tree a_step_in_the_disassembly_view debug::tests::instruction_breakpoints debug::tests::remove_instruction_breakpoints a_right_clicked_call_stack_row_takes_the_list_focus the_debug_toolbar_and_create_configuration_menus_take_contributed_items debug_toolbar variable_menu a_stop_on_a_line_in_view_keeps_the_scroll the_debug_picker_lists_and_starts_the_launch_configurations the_first_scope_expands_only_once_the_variables_view_exists the_find_widget_filters_the_console a_variable_row_draws_its_scopes_indent_guide a_top_frame_past_column_1_injects_the_column_arrow the_call_stack_selects_the_focused_frame_only_after_a_focus_change_it_saw; ui-pair port/fixtures/debug-node (breakpoint, F5, views, REPL, toolbar, `greeting` and `numbers` hovers), menus/view-container-title.json, port/fixtures/ui-pair/debug/hover-find.json, port/fixtures/ui-pair/debug/unverified-breakpoints.json, port/fixtures/ui-pair/debug/call-stack-menu.json, port/fixtures/ui-pair/debug/toolbar.json, port/fixtures/ui-pair/debug/variables-menu.json, port/fixtures/ui-pair/debug/lazy-variable.json, port/fixtures/ui-pair/debug/quick-access.json; shortcuts in port/notes.md |
+| workbench/contrib/debug | workbench contribution | M16 | ported | [3 M] variable_menu.rs: no View Binary Data: debug.contribution.ts registers it only in the rows' `inline` group, and the port's Variables, Watch and hover rows have no inline action bar, no `vscode-debug-memory` file system and no hex editor install prompt (variablesView.ts `VIEW_MEMORY_ID`) <br> [3 M] debug_visualizers.rs: visualized rows draw only in the Variables view; the Watch view's and the debug hover's expression children keep their plain rows (watchExpressionsView.ts:98, debugHover.ts:142 register `VisualizedVariableRenderer`) <br> [3 S] debug_configuration: a picked dynamic configuration keeps its name but not its type (debugConfigurationManager.ts `selectedType`, `DEBUG_SELECTED_TYPE`), so the Run and Debug dropdown and F5 fall back to launch.json's first configuration and the dropdown lists no recent dynamic configurations (debugActionViewItems.ts) <br> [3 M] debug_editor: no inline breakpoint widgets: neither the candidate dots (breakpointEditorContribution.ts `requestBreakpointCandidateLocations`, `breakpointLocations` request on the breakpoints' lines) nor the `InlineBreakpointWidget` of a column breakpoint (ui-pair `debug/variables-menu.json`, line 5 of app.js) | cargo test -p app debug launch_picker_shrinks the_debug_container_more_actions debug_service a_workbench_hover_draws_over_the_debug_hover the_tree_height_keeps_an_above_hover_off_the_hovered_line watch_expression_labels_use_the_monospace_font debug_view debug_task_runner debug_commands debug_console debug::ansi an_ended_session_stays_in_the_picker_until_cleared_or_started_again a_start_or_restart_saves_the_dirty_editors a_hit_breakpoint_enables_its_dependents debug_inline_values debug_hover alt_click_toggles_the_loaded_subtree a_click_on_a_hover_row_focuses_the_tree a_lazy_row_takes_its_value_from_the_eye_button the_find_widget_filters_the_hover_tree disassembly list_tree a_step_in_the_disassembly_view debug::tests::instruction_breakpoints debug::tests::remove_instruction_breakpoints a_right_clicked_call_stack_row_takes_the_list_focus the_debug_toolbar_and_create_configuration_menus_take_contributed_items debug_toolbar variable_menu a_stop_on_a_line_in_view_keeps_the_scroll the_debug_picker_lists_and_starts_the_launch_configurations the_first_scope_expands_only_once_the_variables_view_exists the_find_widget_filters_the_console a_variable_row_draws_its_scopes_indent_guide a_top_frame_past_column_1_injects_the_column_arrow the_call_stack_selects_the_focused_frame_only_after_a_focus_change_it_saw; ui-pair port/fixtures/debug-node (breakpoint, F5, views, REPL, toolbar, `greeting` and `numbers` hovers), menus/view-container-title.json, port/fixtures/ui-pair/debug/hover-find.json, port/fixtures/ui-pair/debug/unverified-breakpoints.json, port/fixtures/ui-pair/debug/call-stack-menu.json, port/fixtures/ui-pair/debug/toolbar.json, port/fixtures/ui-pair/debug/variables-menu.json, port/fixtures/ui-pair/debug/lazy-variable.json, port/fixtures/ui-pair/debug/quick-access.json; shortcuts in port/notes.md |
| workbench/contrib/dropOrPasteInto | workbench contribution | M13 | verified | | commands.ts `configurePreferredPasteAction`/`configurePreferredDropAction`: the widgets' menus and the Paste As pick open user settings JSON at `editor.pasteAs.preferences` or `editor.dropIntoEditor.preferences` (workbench/paste_edits.rs); the `editor.pasteAs.*` and `editor.dropIntoEditor.*` settings come from core-settings.json; ui-pair paste-menu (port/results/language-features.md) |
| workbench/contrib/editSessions | workbench contribution | | removed | | no sign-in/AI by decision (port/notes.md); not ported |
| workbench/contrib/editTelemetry | workbench contribution | | removed | | no AI or Microsoft services by decision (port/notes.md); API stays inert |