Skip to content

Visual Studio Code, rebuilt in Rust

Rust

feat(extensions): port download, auto update and recommendation items

rokartur9ceed0c09daa
diff --git a/native/crates/app/src/extension_recommendations.rs b/native/crates/app/src/extension_recommendations.rs
index 2eea65639af..fbd20ec10bd 100644
--- a/native/crates/app/src/extension_recommendations.rs
+++ b/native/crates/app/src/extension_recommendations.rs
@@ -42,7 +42,7 @@ pub fn read_workspace_file_config(file: &Path) -> Option<ExtensionsConfig> {
read_json(file)?.get("extensions").map(config_from)
}
-fn read_json(path: &Path) -> Option<Value> {
+pub(crate) fn read_json(path: &Path) -> Option<Value> {
let text = std::fs::read_to_string(path).ok()?;
json::parse(&text, &mut Vec::new(), ParseOptions { allow_trailing_comma: true, allow_empty_content: true, ..ParseOptions::default() })
}
diff --git a/native/crates/app/src/menus.rs b/native/crates/app/src/menus.rs
index 08606d9babd..0e994a66e0b 100644
--- a/native/crates/app/src/menus.rs
+++ b/native/crates/app/src/menus.rs
@@ -539,6 +539,8 @@ const WORKBENCH_MENUS: &[Row] = &[
(MenuId::ExtensionContext, None, "workbench.extensions.action.setColorTheme", "Set Color Theme", "_theme_", 0., Some("!inExtensionEditor && extensionStatus == 'installed' && extensionHasColorThemes"), None),
(MenuId::ExtensionContext, None, "workbench.extensions.action.setFileIconTheme", "Set File Icon Theme", "_theme_", 0., Some("!inExtensionEditor && extensionStatus == 'installed' && extensionHasFileIconThemes"), None),
(MenuId::ExtensionContext, None, "workbench.extensions.action.setProductIconTheme", "Set Product Icon Theme", "_theme_", 0., Some("!inExtensionEditor && extensionStatus == 'installed' && extensionHasProductIconThemes"), None),
+ (MenuId::ExtensionContext, None, "workbench.extensions.action.toggleAutoUpdatesForPublisher", "Auto Update (Publisher)", "0_update", 2., Some("extensionStatus == 'installed' && !isBuiltinExtension"), Some("config.extensions.autoUpdate == 'off'")),
+ (MenuId::ExtensionContext, None, "workbench.extensions.action.installUnsigned", "Install", "0_install", 1., Some("extensionStatus == 'uninstalled' && isGalleryExtension && !extensionDisallowInstall && extensionIsUnsigned && (galleryAllPublicRepositorySigned && !extensionIsPrivate || galleryAllPrivateRepositorySigned && extensionIsPrivate)"), None),
(MenuId::ExtensionContext, None, "workbench.extensions.action.switchToPreRlease", "Switch to Pre-Release Version", "0_install", 2., Some("hasGallery && galleryExtensionHasPreReleaseVersion && isPreReleaseExtensionAllowed && !installedExtensionIsOptedToPreRelease && !inExtensionEditor && extensionStatus == 'installed' && !isBuiltinExtension"), None),
(MenuId::ExtensionContext, None, "workbench.extensions.action.switchToRelease", "Switch to Release Version", "0_install", 2., Some("hasGallery && galleryExtensionHasPreReleaseVersion && isExtensionAllowed && installedExtensionIsOptedToPreRelease && !inExtensionEditor && extensionStatus == 'installed' && !isBuiltinExtension"), None),
(MenuId::ExtensionContext, None, "workbench.extensions.action.install.anotherVersion", "Install Specific Version...", "0_install", 3., Some("extensionStatus == 'uninstalled' && isGalleryExtension && isExtensionAllowed && !extensionDisallowInstall"), None),
@@ -549,6 +551,9 @@ const WORKBENCH_MENUS: &[Row] = &[
(MenuId::ExtensionContext, None, "workbench.extensions.action.configureKeybindings", "Keyboard Shortcuts", "2_configure", 2., Some("extensionStatus == 'installed' && extensionHasKeybindings"), None),
(MenuId::ExtensionContext, None, "workbench.extensions.action.ignoreRecommendation", "Ignore Recommendation", "3_recommendations", 1., Some("isExtensionRecommended"), None),
(MenuId::ExtensionContext, None, "workbench.extensions.action.undoIgnoredRecommendation", "Undo Ignored Recommendation", "3_recommendations", 1., Some("isUserIgnoredRecommendation"), None),
+ (MenuId::ExtensionContext, None, "workbench.extensions.action.addExtensionToWorkspaceRecommendations", "Add to Workspace Recommendations", "3_recommendations", 2., Some("workbenchState != 'empty' && !isBuiltinExtension && !isExtensionWorkspaceRecommended && !isUserIgnoredRecommendation && extensionSource != 'resource'"), None),
+ (MenuId::ExtensionContext, None, "workbench.extensions.action.downloadSpecificVersion", "Download Specific Version VSIX...", "", 2., Some("!extensionDisallowInstall && isGalleryExtension"), None),
+ (MenuId::ExtensionContext, None, "workbench.extensions.action.removeExtensionFromWorkspaceRecommendations", "Remove from Workspace Recommendations", "3_recommendations", 2., Some("workbenchState != 'empty' && !isBuiltinExtension && isExtensionWorkspaceRecommended"), None),
(MenuId::ViewContainerTitle, None, "workbench.action.debug.selectandstart", "Start Additional Session", "", 10., Some("viewContainer == 'workbench.view.debug' && debugState != 'inactive' && (config.debug.toolBarLocation == 'docked' || config.debug.hideLauncherWhileDebugging)"), None),
// debug.contribution.ts `registerDebugViewMenuItem(MenuId.DebugVariablesContext/DebugHoverContext/DebugWatchContext, ...)`.
// shortcut: the `inline` View Binary Data items wait for the rows' action bars (ledger debug row).
@@ -890,6 +895,16 @@ pub fn workbench_menus() -> Vec<MenuItem> {
let when = Expr::deserialize("updateState == 'ready' && majorMinorUpdateAvailable");
items.push(MenuItem { menu: MenuId::GlobalActivity, entry, title: "Show Update Release Notes".into(), group: "7_update".into(), order: 1., when });
}
+ // extensions.contribution.ts: Download VSIX comes first on a stable build, Download Pre-Release VSIX elsewhere.
+ let stable = crate::product::is_stable();
+ let downloads = [
+ ("workbench.extensions.action.download", "Download VSIX", if stable { 0. } else { 1. }, "!extensionDisallowInstall && isGalleryExtension"),
+ ("workbench.extensions.action.downloadPreRelease", "Download Pre-Release VSIX", if stable { 1. } else { 0. }, "!extensionDisallowInstall && isGalleryExtension && extensionHasPreReleaseVersion"),
+ ];
+ for (id, title, order, when) in downloads {
+ let entry = Entry::Command { id: id.into(), precondition: None, toggled: None, alt: None };
+ items.push(MenuItem { menu: MenuId::ExtensionContext, entry, title: title.into(), group: String::new(), order, when: Expr::deserialize(when) });
+ }
// stickyScrollActions.ts and breadcrumbsControl.ts: the toggles' checked titles, the only ones the menu shows while it is open.
for (id, setting, title) in [("breadcrumbs.toggle", "breadcrumbs.enabled", "Breadcrumbs"), ("editor.action.toggleStickyScroll", "editor.stickyScroll.enabled", "Sticky Scroll")] {
let entry = Entry::Command { id: id.into(), precondition: None, toggled: Toggled::when(Expr::deserialize(&format!("config.{setting} == true"))), alt: None };
diff --git a/native/crates/app/src/workbench/extension_management.rs b/native/crates/app/src/workbench/extension_management.rs
index a139db6159a..0ba43af6a2e 100644
--- a/native/crates/app/src/workbench/extension_management.rs
+++ b/native/crates/app/src/workbench/extension_management.rs
@@ -9,7 +9,8 @@ use files::watcher::{Change, Watcher};
use futures::StreamExt;
use futures::channel::mpsc;
use exthost::extension_management::Job;
-use exthost::gallery::{ExtensionInfo, Gallery, Operation};
+use anyhow::Context as _;
+use exthost::gallery::{ExtensionInfo, Gallery, GalleryVersion, Operation};
use exthost::scan::ScannedExtension;
use futures::channel::oneshot;
use gpui::{Context, PromptLevel, Task, Window};
@@ -21,6 +22,7 @@ use crate::commands::Outcome;
use crate::file_dialog::FileDialog;
use exthost::main_thread::serialized_error;
use crate::notifications::{Notification, Progress, Severity};
+use crate::quick_input::{Entry, Item, Kind, QuickInput};
/// `SELECT_INSTALL_VSIX_EXTENSION_COMMAND_ID`.
const SELECT_INSTALL_VSIX: &str = "workbench.extensions.action.installVSIX";
@@ -202,10 +204,16 @@ impl Workbench {
/// `extensionsWorkbenchService.install(id)`: the gallery lookup and the download run off the UI thread, then the
/// host installs the VSIX and starts the extension. A built-in cannot be installed from the gallery.
pub(crate) fn install_from_gallery(&mut self, id: String, version: Option<String>, pre_release: bool, cx: &mut Context<Self>) -> Outcome {
+ self.install_from_gallery_verifying(id, version, pre_release, true, cx)
+ }
+
+ /// `install_from_gallery` with `donotVerifySignature` as `!verify`.
+ fn install_from_gallery_verifying(&mut self, id: String, version: Option<String>, pre_release: bool, verify: bool, cx: &mut Context<Self>) -> Outcome {
let installed = self.extensions.iter().find(|extension| extension.id.eq_ignore_ascii_case(&id));
let builtin = installed.is_some_and(|extension| extension.description["isBuiltin"] == true);
let operation = if installed.is_some() { Operation::Update } else { Operation::Install };
- let (downloads, verify_signature) = self.download_settings();
+ let (downloads, verify_setting) = self.download_settings();
+ let verify_signature = verify_setting && verify;
let lower = id.to_lowercase();
if !self.extensions_viewlet.installing.contains(&lower) {
self.extensions_viewlet.installing.push(lower.clone());
@@ -304,24 +312,7 @@ impl Workbench {
if versions.is_empty() {
return cx.update(|window, cx| drop(crate::dialog::show_message_box(window, crate::dialog::InTests::Refuse, PromptLevel::Info, "This extension has no other versions.", None, &["OK"], None, cx)));
}
- let now = chrono::Utc::now().timestamp_millis();
- let mut items = Vec::new();
- for (handle, version) in versions.iter().enumerate() {
- let date = chrono::DateTime::parse_from_rfc3339(&version.date).map_or(now, |date| date.timestamp_millis());
- let mut description = crate::timeline::from_now_ago(date, now);
- if version.is_pre_release_version {
- description.push_str(" (pre-release)");
- }
- if current.as_deref() == Some(version.version.as_str()) {
- description.push_str(" (current)");
- }
- let item = crate::quick_input::Item { handle: handle as i64, id: Some(version.version.clone()), label: version.version.clone(), description: Some(description), pickable: true, ..Default::default() };
- items.push(crate::quick_input::Entry::Item(item));
- }
- let mut input = crate::quick_input::QuickInput::new(0, crate::quick_input::Kind::QuickPick);
- input.placeholder = Some("Select Version to Install".into());
- input.match_on_detail = true;
- input.set_items(items);
+ let input = version_pick(&versions, current.as_deref(), "Select Version to Install");
let picked = workbench.update_in(cx, |workbench, window, cx| workbench.choose(input, window, cx))?;
let Some(picked) = picked.await.ok().and_then(Result::ok).and_then(|picked| picked.as_i64()) else { return Ok(()) };
let version = &versions[picked as usize];
@@ -334,6 +325,110 @@ impl Workbench {
.detach();
}
+ /// `InstallAction.run` for an unsigned gallery extension of a gallery whose repository is all signed: "Install
+ /// Anyway" installs it with `donotVerifySignature`.
+ pub(super) fn install_unsigned(&mut self, extension: &crate::extensions_model::Extension, window: &mut Window, cx: &mut Context<Self>) {
+ let id = extension.identifier().id;
+ let message = format!("'{}' is an extension from an unknown source. Are you sure you want to install?", extension.display_name());
+ let answer = crate::dialog::show_message_box(window, crate::dialog::InTests::Refuse, PromptLevel::Warning, &message, Some("Extension is not signed."), &["Install Anyway", "Cancel"], None, cx);
+ cx.spawn(async move |workbench, cx| {
+ if matches!(answer.await, Ok((0, _))) {
+ let _ = workbench.update(cx, |workbench, cx| drop(workbench.install_from_gallery_verifying(id, None, false, false, cx)));
+ }
+ })
+ .detach();
+ }
+
+ /// extensionsWorkbenchService.ts `downloadVSIX`: `any` picks the version first (`pickVersionToDownload`), more
+ /// than one platform asks for one, then the VSIX goes into the picked folder with the progress in a notification.
+ pub(super) fn download_vsix(&mut self, id: String, version_kind: VersionKind, window: &mut Window, cx: &mut Context<Self>) {
+ let gallery = self.gallery();
+ cx.spawn_in(window, async move |workbench, cx| {
+ let mut version = None;
+ if version_kind == VersionKind::Any {
+ let (all_gallery, all_id) = (gallery.clone(), id.clone());
+ let versions = match cx.background_executor().spawn(async move { all_gallery.get_all_versions(&all_id) }).await {
+ Ok(versions) => versions,
+ Err(error) => return workbench.update(cx, |workbench, cx| notify_failure(workbench, format!("{error:#}"), cx)),
+ };
+ if versions.is_empty() {
+ return cx.update(|window, cx| drop(crate::dialog::show_message_box(window, crate::dialog::InTests::Refuse, PromptLevel::Info, "This extension has no other versions.", None, &["OK"], None, cx)));
+ }
+ let input = version_pick(&versions, None, "Select Version to Download");
+ let picked = workbench.update_in(cx, |workbench, window, cx| workbench.choose(input, window, cx))?;
+ let Some(picked) = picked.await.ok().and_then(Result::ok).and_then(|picked| picked.as_i64()) else { return Ok(()) };
+ version = Some(versions[picked as usize].clone());
+ }
+ let info = ExtensionInfo { id: id.clone(), version: version.as_ref().map(|version| version.version.clone()), pre_release: version_kind == VersionKind::Prerelease, ..ExtensionInfo::default() };
+ let compatible = version.is_none();
+ let executor = cx.background_executor().clone();
+ let lookup = |target_platform| {
+ let (gallery, info) = (gallery.clone(), info.clone());
+ executor.spawn(async move {
+ let found = gallery.get_extensions_for_platform(std::slice::from_ref(&info), compatible, target_platform)?;
+ found.into_iter().next().with_context(|| format!("Extension '{}' not found.", info.id))
+ })
+ };
+ let found = match lookup(exthost::gallery::CURRENT_TARGET_PLATFORM).await {
+ Ok(found) => found,
+ Err(error) => return workbench.update(cx, |workbench, cx| notify_failure(workbench, format!("{error:#}"), cx)),
+ };
+ let platforms = version.as_ref().map_or(&found.all_target_platforms, |version| &version.target_platforms);
+ let mut options: Vec<(&'static str, &str)> = Vec::new();
+ for &platform in platforms {
+ if platform != exthost::gallery::UNKNOWN && platform != exthost::gallery::UNIVERSAL {
+ options.push((platform, if platform == exthost::gallery::UNDEFINED { "All Platforms" } else { exthost::gallery::target_platform_label(platform) }));
+ }
+ }
+ let mut target_platform = found.target_platform;
+ if options.len() > 1 {
+ options.sort_by_key(|(_, label)| label.to_lowercase());
+ let items = options.iter().enumerate().map(|(handle, (_, label))| Entry::Item(Item { handle: handle as i64, label: (*label).into(), pickable: true, ..Item::default() })).collect();
+ let mut input = QuickInput::new(0, Kind::QuickPick);
+ input.placeholder = Some("Please select the platform for which you want to download the VSIX".into());
+ input.set_items(items);
+ let picked = workbench.update_in(cx, |workbench, window, cx| workbench.choose(input, window, cx))?;
+ let Some(picked) = picked.await.ok().and_then(Result::ok).and_then(|picked| picked.as_i64()) else { return Ok(()) };
+ target_platform = options[picked as usize].0;
+ }
+ let found = match target_platform == found.target_platform {
+ true => found,
+ false => match lookup(target_platform).await {
+ Ok(found) => found,
+ Err(error) => return workbench.update(cx, |workbench, cx| notify_failure(workbench, format!("{error:#}"), cx)),
+ },
+ };
+ let dialog = FileDialog { title: Some("Select folder to download the VSIX".into()), button_label: Some("Download".into()), folders: true, ..FileDialog::default() };
+ let picked = workbench.update(cx, |workbench, cx| workbench.show_open_dialog(dialog, cx))?;
+ let Some(folder) = picked.await.unwrap_or_default().into_iter().next() else { return Ok(()) };
+ let suffix = match target_platform {
+ exthost::gallery::UNDEFINED | exthost::gallery::UNIVERSAL | exthost::gallery::UNKNOWN => String::new(),
+ platform => format!("-{platform}"),
+ };
+ let location = folder.join(format!("{}-{}{suffix}.vsix", found.id, found.version));
+ let mut progress = Notification::new(Severity::Info, "Downloading VSIX...");
+ progress.progress = Some(Progress { infinite: true, ..Progress::default() });
+ let key = workbench.update(cx, |workbench, cx| {
+ cx.notify();
+ workbench.notify(progress)
+ })?;
+ let downloaded = cx.background_executor().spawn(async move { gallery.download_to(&found, &location) }).await;
+ workbench.update_in(cx, |workbench, window, cx| {
+ if let Some(key) = key {
+ workbench.close_notification(key, window, cx);
+ }
+ match downloaded {
+ Ok(()) => {
+ workbench.notify(Notification::new(Severity::Info, "Successfully downloaded the VSIX"));
+ }
+ Err(error) => workbench.notify_error(format!("Error while downloading the VSIX: {error:#}")),
+ }
+ cx.notify();
+ })
+ })
+ .detach();
+ }
+
/// The gallery the installs query: Open VSX unless a test points `gallery_url` elsewhere.
pub(super) fn gallery(&self) -> Gallery {
Gallery { service_url: self.gallery_url.clone(), product_version: crate::VERSION.clone() }
@@ -599,6 +694,42 @@ pub(crate) fn id_and_version(arg: &str) -> (String, Option<String>) {
}
}
+/// The `versionKind` of `downloadVSIX`.
+#[derive(Clone, Copy, PartialEq, Eq)]
+pub(super) enum VersionKind {
+ Release,
+ Prerelease,
+ Any,
+}
+
+/// The version pick of `InstallAnotherVersionAction` and `pickVersionToDownload`: each version with how long ago it
+/// shipped, `(pre-release)` and `(current)` after it.
+fn version_pick(versions: &[GalleryVersion], current: Option<&str>, placeholder: &str) -> QuickInput {
+ let now = chrono::Utc::now().timestamp_millis();
+ let mut items = Vec::new();
+ for (handle, version) in versions.iter().enumerate() {
+ let date = chrono::DateTime::parse_from_rfc3339(&version.date).map_or(now, |date| date.timestamp_millis());
+ let mut description = crate::timeline::from_now_ago(date, now);
+ if version.is_pre_release_version {
+ description.push_str(" (pre-release)");
+ }
+ if current == Some(version.version.as_str()) {
+ description.push_str(" (current)");
+ }
+ items.push(Entry::Item(Item { handle: handle as i64, id: Some(version.version.clone()), label: version.version.clone(), description: Some(description), pickable: true, ..Item::default() }));
+ }
+ let mut input = QuickInput::new(0, Kind::QuickPick);
+ input.placeholder = Some(placeholder.into());
+ input.match_on_detail = true;
+ input.set_items(items);
+ input
+}
+
+fn notify_failure(workbench: &mut Workbench, message: String, cx: &mut Context<Workbench>) {
+ workbench.notify_error(message);
+ cx.notify();
+}
+
/// The prompt of `installExtension` with a justification: its message, its detail and the install button's label.
fn install_prompt(display_name: &str, publisher_display_name: &str, justification: &Value) -> (String, String, String) {
let message = format!("Would you like to install '{display_name}' extension from '{publisher_display_name}'?");
diff --git a/native/crates/app/src/workbench/extension_management/tests.rs b/native/crates/app/src/workbench/extension_management/tests.rs
index 844c55b9bfd..3a381c3d536 100644
--- a/native/crates/app/src/workbench/extension_management/tests.rs
+++ b/native/crates/app/src/workbench/extension_management/tests.rs
@@ -150,6 +150,29 @@ fn install_specific_version_installs_the_picked_version(cx: &mut TestAppContext)
assert_eq!(sent_jobs(&fixture.messages), ["a.yaml"]);
}
+/// extensionsWorkbenchService.ts `downloadVSIX` with `any`: every version of the gallery extension is offered, then the
+/// folder to save the VSIX in is asked for.
+#[gpui::test]
+fn download_specific_version_picks_a_version_then_a_folder(cx: &mut TestAppContext) {
+ let (_fixture, workbench, cx) = workbench_on_gallery("download-version", &[("a.yaml", &[], &[])], cx);
+ workbench.update(cx, |workbench, _| workbench.load_keybindings(crate::keybindings::default_keybindings(&[]), "/nonexistent/User/keybindings.json".into()));
+ workbench.update_in(cx, |workbench, window, cx| drop(workbench.execute_command("workbench.extensions.action.downloadSpecificVersion", vec![json!("a.yaml")], window, cx)));
+ cx.run_until_parked();
+ let picks = workbench.read_with(cx, |workbench, _| {
+ let input = workbench.quick_inputs.current().expect("the version pick");
+ let labels = input.order.iter().map(|row| input.rows[*row].item.label.clone());
+ (input.placeholder.clone().unwrap_or_default(), labels.collect::<Vec<_>>())
+ });
+ assert_eq!(picks, ("Select Version to Download".to_string(), vec!["2.1.2026112008".to_string(), "2.0.0".to_string()]));
+ cx.simulate_keystrokes("down enter");
+ cx.run_until_parked();
+ assert!(cx.did_prompt_for_paths(), "the folder dialog opens");
+ cx.simulate_path_prompt_response(|options| {
+ assert!(options.directories && !options.files);
+ None
+ });
+}
+
/// The deltas sent to the host: the ids started and the ids stopped.
fn sent_deltas(messages: &Receiver<HostMessage>) -> Vec<(Vec<String>, Vec<String>)> {
let mut deltas = Vec::new();
diff --git a/native/crates/app/src/workbench/extensions_list_view.rs b/native/crates/app/src/workbench/extensions_list_view.rs
index bcde8b1034c..08e71d1f7f1 100644
--- a/native/crates/app/src/workbench/extensions_list_view.rs
+++ b/native/crates/app/src/workbench/extensions_list_view.rs
@@ -385,7 +385,7 @@ impl Workbench {
let foreground = self.foreground_or("sideBar.foreground");
let time = format!("{}ms", activation.code_loading + activation.activate_call);
let selector = format!("activation-time {} {time}", extension.identifier().id);
- Some(div().debug_selector(move || selector).ml(px(2.)).flex().items_center().text_size(px(11.)).child(self.icon("history", 16., 16., foreground)).child(time))
+ Some(div().debug_selector(move || selector).ml(px(2.)).flex().items_center().text_size(px(11.)).child(self.icon("history", 16., 16., foreground).mr(px(2.))).child(time))
}
/// `RatingsWidget` small: one star and the rating rounded to halves, when someone rated it.
@@ -578,6 +578,16 @@ impl Workbench {
context.insert("isPreReleaseExtensionAllowed".into(), json!(true));
context.insert("extensionDisallowInstall".into(), json!(false));
context.insert("isWorkspaceScopedExtension".into(), json!(false));
+ if let Some(local) = &extension.local {
+ context.insert("extensionSource".into(), local.description["__metadata"]["source"].clone());
+ }
+ // extensionGalleryManifestService.ts gives the product's gallery `signing.allPublicRepositorySigned: true`.
+ context.insert("galleryAllPublicRepositorySigned".into(), json!(true));
+ context.insert("galleryAllPrivateRepositorySigned".into(), json!(false));
+ context.insert("extensionIsUnsigned".into(), json!(extension.gallery.as_ref().is_some_and(|gallery| !gallery.is_signed)));
+ context.insert("extensionIsPrivate".into(), json!(extension.gallery.as_ref().is_some_and(|gallery| gallery.private)));
+ let local_has_pre_release = extension.local.as_ref().is_some_and(|local| local.description["__metadata"]["hasPreReleaseVersion"] == true);
+ context.insert("extensionHasPreReleaseVersion".into(), json!(extension.gallery.as_ref().is_some_and(|gallery| gallery.has_pre_release_version) || local_has_pre_release));
// Workspace recommendations are the only recommendations the port has (`getAllRecommendationsWithReason`).
let lower = id.to_lowercase();
let workspace_recommended = self.workspace_recommendations().contains(&lower);
@@ -631,7 +641,8 @@ impl Workbench {
let another_version = !extension.is_builtin() && identifier.uuid.is_some();
install.push(action("workbench.extensions.action.install.anotherVersion", "Install Specific Version...", another_version));
install.push(action("extensions.uninstall", "Uninstall", !extension.is_builtin()));
- } else if extension.state == ExtensionState::Uninstalled && gallery {
+ } else if extension.state == ExtensionState::Uninstalled && gallery && context["extensionIsUnsigned"] == false {
+ // The unsigned extension's `installUnsigned` item is its Install.
install.insert(0, command("extensions.install", "Install"));
}
update.extend(menu(&|group| group == UPDATE_ACTIONS_GROUP));
diff --git a/native/crates/app/src/workbench/extensions_list_view/tests.rs b/native/crates/app/src/workbench/extensions_list_view/tests.rs
index 937fbe51485..018f8a49939 100644
--- a/native/crates/app/src/workbench/extensions_list_view/tests.rs
+++ b/native/crates/app/src/workbench/extensions_list_view/tests.rs
@@ -70,7 +70,7 @@ fn the_manage_menu_lists_the_extension_context_menu(cx: &mut TestAppContext) {
};
let enablement = ["Enable (disabled)", "Enable (Workspace) (disabled)", "---", "Disable", "Disable (Workspace) (disabled)", "---"];
let context = ["---", "Copy", "Copy Extension ID", "---", "Settings"];
- assert_eq!(menu(&configured), [&enablement[..], &["Auto Update", "---", "Install Specific Version... (disabled)", "Uninstall"], &context[..], &["---", "Report Extension"]].concat());
+ assert_eq!(menu(&configured), [&enablement[..], &["Auto Update", "Auto Update (Publisher) (disabled)", "---", "Install Specific Version... (disabled)", "Uninstall"], &context[..], &["---", "Report Extension"]].concat());
assert_eq!(menu(&builtin), [&enablement[..], &["Install Specific Version... (disabled)", "Uninstall (disabled)", "---", "Copy", "Copy Extension ID"]].concat());
}
@@ -116,30 +116,34 @@ fn the_manage_menu_sets_a_theme_of_the_extension(cx: &mut TestAppContext) {
assert_eq!(picks(cx), ("Select File Icon Theme".to_string(), vec!["Seti (Visual Studio Code)".to_string()]));
}
-/// extensions.contribution.ts: an uninstalled gallery extension offers Install Specific Version..., and the Ignore
-/// Recommendation pair toggles the profile's globally ignored recommendations.
+/// extensions.contribution.ts: an uninstalled gallery extension offers Install (unsigned when its gallery entry has no
+/// signature), Install Specific Version... and the Download VSIX items, and the Ignore Recommendation pair toggles the
+/// profile's globally ignored recommendations.
#[gpui::test]
fn the_manage_menu_installs_a_version_and_toggles_an_ignored_recommendation(cx: &mut TestAppContext) {
let app_root = Path::new(env!("VSCODE_SRC")).to_path_buf();
let themes = scan_extension(&app_root.join("extensions/theme-defaults"), true).unwrap();
let theme = load_theme(&[themes], "Dark Modern").unwrap();
let (workbench, cx) = cx.add_window_view(|_, cx| Workbench::new(theme, app_root.clone(), None, Languages::new(&[]), crate::default_settings(), HostSync::new(std::sync::mpsc::channel().0), cx));
- let gallery = exthost::gallery::GalleryExtension { id: "pub.ext".into(), uuid: "uuid-pub.ext".into(), ..Default::default() };
+ let gallery = exthost::gallery::GalleryExtension { id: "pub.ext".into(), uuid: "uuid-pub.ext".into(), is_signed: true, ..Default::default() };
let extension = Extension { local: None, gallery: Some(gallery), state: ExtensionState::Uninstalled, enablement: EnablementState::EnabledGlobally, running: false, restart_required: false };
- let titles = |cx: &mut gpui::VisualTestContext| {
- let actions = workbench.update_in(cx, |workbench, window, _| workbench.manage_extension_actions(&extension, false, window));
+ let ids = |extension: &Extension, cx: &mut gpui::VisualTestContext| {
+ let actions = workbench.update_in(cx, |workbench, window, _| workbench.manage_extension_actions(extension, false, window));
actions.into_iter().filter_map(|action| match action {
- MenuAction::Command { title, .. } => Some(title),
+ MenuAction::Command { id, .. } => Some(id.trim_start_matches("workbench.extensions.action.").to_owned()),
_ => None,
}).collect::<Vec<_>>()
};
- assert_eq!(titles(cx), ["Install", "Install Specific Version...", "Copy", "Copy Extension ID", "Copy Link"]);
+ assert_eq!(ids(&extension, cx), ["extensions.install", "install.anotherVersion", "copyExtension", "copyExtensionId", "copyLink", "download", "downloadSpecificVersion"]);
+ let unsigned_gallery = exthost::gallery::GalleryExtension { is_signed: false, ..extension.gallery.clone().unwrap() };
+ let unsigned = Extension { gallery: Some(unsigned_gallery), ..extension.clone() };
+ assert_eq!(ids(&unsigned, cx)[..2], ["installUnsigned", "install.anotherVersion"]);
workbench.update_in(cx, |workbench, window, cx| drop(workbench.execute_command("workbench.extensions.action.ignoreRecommendation", vec![json!("Pub.Ext")], window, cx)));
let stored = workbench.read_with(cx, |workbench, _| workbench.profile_storage.lock().unwrap().get(crate::extension_recommendations::IGNORED_RECOMMENDATIONS_KEY).map(str::to_owned));
assert_eq!(stored.as_deref(), Some(r#"["pub.ext"]"#));
- assert_eq!(titles(cx).last().map(String::as_str), Some("Undo Ignored Recommendation"));
+ assert!(ids(&extension, cx).contains(&"undoIgnoredRecommendation".to_owned()));
workbench.update_in(cx, |workbench, window, cx| drop(workbench.execute_command("workbench.extensions.action.undoIgnoredRecommendation", vec![json!("pub.ext")], window, cx)));
- assert_eq!(titles(cx).last().map(String::as_str), Some("Copy Link"));
+ assert!(!ids(&extension, cx).contains(&"undoIgnoredRecommendation".to_owned()));
let gallery = exthost::gallery::GalleryExtension { id: "pub.ext".into(), uuid: "uuid-pub.ext".into(), has_pre_release_version: true, ..Default::default() };
let switch = |pre_release: bool, cx: &mut gpui::VisualTestContext| {
@@ -175,3 +179,52 @@ fn an_activated_extensions_row_shows_its_activation_time(cx: &mut TestAppContext
cx.run_until_parked();
assert!(cx.debug_bounds("activation-time test.timed 33ms").is_some());
}
+
+/// extensions.contribution.ts: with auto update off, Auto Update (Publisher) selects the publisher in
+/// `extensions.autoUpdate`'s storage; in a folder workspace, Add to and Remove from Workspace Recommendations write the
+/// folder's extensions.json (workspaceExtensionsConfig.ts `toggleRecommendation`).
+#[gpui::test]
+fn the_manage_menu_auto_updates_a_publisher_and_toggles_a_workspace_recommendation(cx: &mut TestAppContext) {
+ let app_root = Path::new(env!("VSCODE_SRC")).to_path_buf();
+ let theme = load_theme(&[scan_extension(&app_root.join("extensions/theme-defaults"), true).unwrap()], "Dark Modern").unwrap();
+ let dir = std::env::temp_dir().join(format!("vsrustium-workspace-recommendation-{}", std::process::id()));
+ let _ = std::fs::remove_dir_all(&dir);
+ std::fs::create_dir_all(&dir).unwrap();
+ let folder = config::workspace::Workspace::folder(dir.clone());
+ let settings = config::service::Settings::load(config::registry::Registry::with_extensions(&[]), dir.join("User"), Some(folder.clone()));
+ let settings = std::sync::Arc::new(std::sync::Mutex::new(settings));
+ let (workbench, cx) = cx.add_window_view(|_, cx| Workbench::new(theme, app_root.clone(), Some(folder), Languages::new(&[]), settings, HostSync::new(std::sync::mpsc::channel().0), cx));
+ let local = ScannedExtension { id: "pub.ext".into(), location: app_root.clone(), description: json!({ "publisher": "Pub" }) };
+ workbench.update(cx, |workbench, _| {
+ workbench.extensions_viewlet.installed = vec![local];
+ workbench.update_setting("extensions.autoUpdate", json!("off"));
+ });
+ let menu = |cx: &mut gpui::VisualTestContext| {
+ let extension = workbench.read_with(cx, |workbench, _| workbench.find_extension("pub.ext").unwrap());
+ let actions = workbench.update_in(cx, |workbench, window, _| workbench.manage_extension_actions(&extension, false, window));
+ actions.into_iter().filter_map(|action| match action {
+ MenuAction::Command { id, enabled: true, .. } => Some(id.trim_start_matches("workbench.extensions.action.").to_owned()),
+ _ => None,
+ }).collect::<Vec<_>>()
+ };
+ let run = |command: &str, cx: &mut gpui::VisualTestContext| {
+ workbench.update_in(cx, |workbench, window, cx| drop(workbench.execute_command(&format!("workbench.extensions.action.{command}"), vec![json!("pub.ext")], window, cx)));
+ cx.run_until_parked();
+ };
+ assert!(menu(cx).contains(&"toggleAutoUpdatesForPublisher".to_owned()));
+ run("toggleAutoUpdatesForPublisher", cx);
+ let auto_updated = |cx: &mut gpui::VisualTestContext| workbench.read_with(cx, |workbench, _| workbench.is_auto_update_enabled_for(&workbench.find_extension("pub.ext").unwrap()));
+ assert!(auto_updated(cx));
+ run("toggleAutoUpdatesForPublisher", cx);
+ assert!(!auto_updated(cx));
+
+ let recommendations = || serde_json::from_str::<serde_json::Value>(&std::fs::read_to_string(dir.join(".vscode/extensions.json")).unwrap()).unwrap()["recommendations"].clone();
+ assert!(!menu(cx).contains(&"removeExtensionFromWorkspaceRecommendations".to_owned()));
+ run("addExtensionToWorkspaceRecommendations", cx);
+ assert_eq!(recommendations(), json!(["pub.ext"]));
+ assert!(menu(cx).contains(&"removeExtensionFromWorkspaceRecommendations".to_owned()));
+ assert!(!menu(cx).contains(&"addExtensionToWorkspaceRecommendations".to_owned()));
+ run("removeExtensionFromWorkspaceRecommendations", cx);
+ assert_eq!(recommendations(), json!([]));
+ std::fs::remove_dir_all(&dir).unwrap();
+}
diff --git a/native/crates/app/src/workbench/extensions_view.rs b/native/crates/app/src/workbench/extensions_view.rs
index 5f2f0d34efc..f360fb042ba 100644
--- a/native/crates/app/src/workbench/extensions_view.rs
+++ b/native/crates/app/src/workbench/extensions_view.rs
@@ -15,6 +15,7 @@ use serde_json::{Value, json};
use super::Workbench;
use super::extension_bisect::BisectState;
+use super::extension_management::VersionKind;
use super::themes::ThemeType;
use super::input_box_view::InputView;
use super::view_panes::{MINIMUM_BODY_SIZE, PaneContainer};
@@ -564,6 +565,24 @@ impl Workbench {
}
Outcome::done()
});
+ self.commands.register("workbench.extensions.action.installUnsigned", |workbench, args, window, cx| {
+ if let Some(extension) = args.first().and_then(Value::as_str).and_then(|id| workbench.find_extension(id)) {
+ workbench.install_unsigned(&extension, window, cx);
+ }
+ Outcome::done()
+ });
+ let downloads = [
+ ("workbench.extensions.action.download", VersionKind::Release),
+ ("workbench.extensions.action.downloadPreRelease", VersionKind::Prerelease),
+ ("workbench.extensions.action.downloadSpecificVersion", VersionKind::Any),
+ ];
+ for (command, version_kind) in downloads {
+ self.commands.register(command, move |workbench, args, window, cx| {
+ let Some(id) = args.first().and_then(Value::as_str) else { return Outcome::error("Extension id required.") };
+ workbench.download_vsix(id.to_owned(), version_kind, window, cx);
+ Outcome::done()
+ });
+ }
// `TogglePreReleaseExtensionAction.run`: opens the extension and installs it with the other kind.
for (command, pre_release) in [("workbench.extensions.action.switchToPreRlease", true), ("workbench.extensions.action.switchToRelease", false)] {
self.commands.register(command, move |workbench, args, window, cx| {
@@ -580,6 +599,13 @@ impl Workbench {
Outcome::done()
});
}
+ for command in ["workbench.extensions.action.addExtensionToWorkspaceRecommendations", "workbench.extensions.action.removeExtensionFromWorkspaceRecommendations"] {
+ self.commands.register(command, |workbench, args, window, cx| {
+ let id = args.first().and_then(Value::as_str).unwrap_or_default();
+ workbench.toggle_workspace_recommendation(id, window, cx);
+ Outcome::done()
+ });
+ }
self.commands.register("workbench.extensions.action.copyExtension", |workbench, args, _, cx| {
let Some(extension) = args.first().and_then(Value::as_str).and_then(|id| workbench.find_extension(id)) else { return Outcome::done() };
cx.write_to_clipboard(gpui::ClipboardItem::new_string(copy_text(&extension)));
@@ -623,8 +649,17 @@ impl Workbench {
});
}
self.commands.register("workbench.extensions.action.toggleAutoUpdateForExtension", |workbench, args, _, cx| {
- let id = args.first().and_then(Value::as_str).unwrap_or_default().to_lowercase();
- workbench.toggle_auto_update_for(&id, cx);
+ let id = args.first().and_then(Value::as_str).unwrap_or_default();
+ if let Some(extension) = workbench.local_extensions().into_iter().find(|extension| extension.identifier().id.eq_ignore_ascii_case(id)) {
+ workbench.toggle_auto_update_for(&extension, cx);
+ }
+ Outcome::done()
+ });
+ self.commands.register("workbench.extensions.action.toggleAutoUpdatesForPublisher", |workbench, args, _, cx| {
+ let id = args.first().and_then(Value::as_str).unwrap_or_default();
+ if let Some(extension) = workbench.local_extensions().into_iter().find(|extension| extension.identifier().id.eq_ignore_ascii_case(id)) {
+ workbench.toggle_auto_update_for_publisher(extension.publisher(), cx);
+ }
Outcome::done()
});
// The list commands act on the focused list: the extensions list here, else whoever registered before.
@@ -1186,7 +1221,7 @@ impl Workbench {
let id = extension.identifier().id.to_lowercase();
let wanted = match on {
true => !selected.contains(&format!("-{id}")) && !matches!(extension.enablement, EnablementState::DisabledGlobally | EnablementState::DisabledWorkspace),
- false => selected.contains(&id),
+ false => auto_updated_while_off(&selected, &extension),
};
let published = extension.gallery.as_ref().and_then(|gallery| iso_millis(&gallery.last_updated)).unwrap_or(0.);
let delayed = published > 0. && now - published < delay_hours * 3_600_000.;
@@ -1202,15 +1237,44 @@ impl Workbench {
storage.get("extensions.autoUpdate").and_then(|text| serde_json::from_str::<Vec<String>>(text).ok()).unwrap_or_default()
}
- /// `ToggleAutoUpdateForExtensionAction`: with auto update on, `-id` marks it skipped; off, `id` marks it updated.
- fn toggle_auto_update_for(&mut self, id: &str, cx: &mut Context<Self>) {
+ /// `ToggleAutoUpdateForExtensionAction` (`updateAutoUpdateEnablementFor(extension)`): with auto update on, `-id`
+ /// marks it skipped; off, `id` marks it updated and `-id` skips it while its publisher is auto updated.
+ fn toggle_auto_update_for(&mut self, extension: &Extension, cx: &mut Context<Self>) {
let mut selected = self.auto_update_selection();
- let on = self.auto_update_on();
- let entry = if on { format!("-{id}") } else { id.to_owned() };
- match selected.iter().position(|selected| *selected == entry) {
- Some(index) => drop(selected.remove(index)),
- None => selected.push(entry),
+ let id = extension.identifier().id.to_lowercase();
+ let skip = format!("-{id}");
+ let remove = |selected: &mut Vec<String>, entry: &str| selected.retain(|selected| selected != entry);
+ if self.auto_update_on() {
+ match selected.contains(&skip) {
+ true => remove(&mut selected, &skip),
+ false => selected.push(skip),
+ }
+ } else {
+ let enable = !auto_updated_while_off(&selected, extension);
+ let publisher = selected.contains(&extension.publisher().to_lowercase());
+ remove(&mut selected, &id);
+ remove(&mut selected, &skip);
+ match (enable, publisher) {
+ (true, false) => selected.push(id),
+ (false, true) => selected.push(skip),
+ _ => {}
+ }
+ }
+ self.write_auto_update_selection(selected, cx);
+ }
+
+ /// `ToggleAutoUpdatesForPublisherAction` (`updateAutoUpdateEnablementFor(publisher)`), run while auto update is off.
+ fn toggle_auto_update_for_publisher(&mut self, publisher: &str, cx: &mut Context<Self>) {
+ let mut selected = self.auto_update_selection();
+ let publisher = publisher.to_lowercase();
+ match selected.contains(&publisher) {
+ true => selected.retain(|selected| *selected != publisher),
+ false => selected.push(publisher),
}
+ self.write_auto_update_selection(selected, cx);
+ }
+
+ fn write_auto_update_selection(&mut self, selected: Vec<String>, cx: &mut Context<Self>) {
let mut storage = self.profile_storage.lock().unwrap();
match selected.is_empty() {
true => storage.delete("extensions.autoUpdate"),
@@ -1228,12 +1292,11 @@ impl Workbench {
/// `isAutoUpdateEnabledFor(extension)`.
pub(super) fn is_auto_update_enabled_for(&self, extension: &Extension) -> bool {
- let on = self.auto_update_on();
let id = extension.identifier().id.to_lowercase();
let selected = self.auto_update_selection();
- match on {
+ match self.auto_update_on() {
true => !selected.contains(&format!("-{id}")),
- false => selected.contains(&id),
+ false => auto_updated_while_off(&selected, extension),
}
}
@@ -1314,6 +1377,12 @@ fn image_format(bytes: &[u8]) -> Option<ImageFormat> {
}
}
+/// `shouldAutoUpdateExtension` with auto update off: the extension is selected, or its publisher is and it is not skipped.
+fn auto_updated_while_off(selected: &[String], extension: &Extension) -> bool {
+ let id = extension.identifier().id.to_lowercase();
+ selected.contains(&id) || (selected.contains(&extension.publisher().to_lowercase()) && !selected.contains(&format!("-{id}")))
+}
+
/// `Date.parse` of the gallery's ISO 8601 UTC dates (`2024-01-31T12:00:00.000Z`), in milliseconds.
pub fn iso_millis(date: &str) -> Option<f64> {
let (day, time) = date.split_once('T')?;
diff --git a/native/crates/app/src/workbench/workspace_recommendations.rs b/native/crates/app/src/workbench/workspace_recommendations.rs
index 53d74bf820f..41008be5fdd 100644
--- a/native/crates/app/src/workbench/workspace_recommendations.rs
+++ b/native/crates/app/src/workbench/workspace_recommendations.rs
@@ -204,6 +204,51 @@ impl Workbench {
Outcome::done()
}
+ /// workspaceExtensionsConfig.ts `toggleRecommendation`: removes the extension from the folders and workspace file
+ /// recommending it, else adds it to the picked ones (`pickWorkspaceOrFolders` asks only when there is a choice).
+ pub(super) fn toggle_workspace_recommendation(&mut self, id: &str, window: &mut Window, cx: &mut Context<Self>) {
+ let id = id.to_lowercase();
+ let Some(workspace) = self.settings.lock().unwrap().workspace.clone() else { return };
+ let recommends = |config: &recommendations::ExtensionsConfig| config.recommendations.iter().flatten().any(|recommended| recommended.eq_ignore_ascii_case(&id));
+ let workspace_recommended = workspace.file.as_deref().and_then(recommendations::read_workspace_file_config).is_some_and(|config| recommends(&config));
+ let recommended_folders: Vec<_> = workspace.folders.iter().filter(|folder| recommends(&recommendations::read_folder_config(&folder.path))).collect();
+ let add = !workspace_recommended && recommended_folders.is_empty();
+ let (folders, workspace_file, placeholder) = match add {
+ true => (workspace.folders.iter().collect(), workspace.file.clone(), "Add extension recommendation to"),
+ false => (recommended_folders, workspace.file.clone().filter(|_| workspace_recommended), "Remove extension recommendation from"),
+ };
+ let mut targets: Vec<(PathBuf, &'static [&'static str])> = folders.iter().map(|folder| (folder_extensions_file(&folder.path), &[][..])).collect();
+ targets.extend(workspace_file.map(|file| (file, &["extensions"][..])));
+ if targets.len() == 1 {
+ let (file, prefix) = &targets[0];
+ return self.notify_recommendation_write(write_recommendation(file, prefix, &id, add), cx);
+ }
+ let mut items: Vec<Entry> = folders.iter().enumerate().map(|(handle, folder)| Entry::Item(Item { handle: handle as i64, label: folder.name.clone(), description: Some("Workspace Folder".into()), ..Item::default() })).collect();
+ if targets.len() > folders.len() {
+ items.push(Entry::Separator(None));
+ items.push(Entry::Item(Item { handle: folders.len() as i64, label: "Workspace".into(), ..Item::default() }));
+ }
+ let mut input = QuickInput::new(0, Kind::QuickPick);
+ input.placeholder = Some(placeholder.into());
+ input.can_select_many = true;
+ input.set_items(items);
+ let picked = self.choose(input, window, cx);
+ cx.spawn(async move |workbench, cx| {
+ let Some(picked) = picked.await.ok().and_then(Result::ok) else { return };
+ let handles: Vec<usize> = picked.as_array().into_iter().flatten().filter_map(Value::as_u64).map(|handle| handle as usize).collect();
+ let written = handles.iter().try_for_each(|&handle| write_recommendation(&targets[handle].0, targets[handle].1, &id, add));
+ drop(workbench.update(cx, |workbench, cx| workbench.notify_recommendation_write(written, cx)));
+ })
+ .detach();
+ }
+
+ fn notify_recommendation_write(&mut self, written: std::io::Result<()>, cx: &mut Context<Self>) {
+ if let Err(error) = written {
+ self.notify_error(error.to_string());
+ }
+ cx.notify();
+ }
+
/// `getSelectionPosition`: after the last entry of the array at `path`, else just inside its bracket.
fn open_at_recommendations(&mut self, path: PathBuf, json_path: &[Segment], pinned: bool, window: &mut Window, cx: &mut Context<Self>) {
let text = std::fs::read_to_string(&path).unwrap_or_default();
@@ -226,3 +271,40 @@ impl Workbench {
cx.notify();
}
}
+
+/// The folder's extensions.json whose `recommendations` count (`.vsrustium/` wins per key), else where a new one goes.
+fn folder_extensions_file(folder: &Path) -> PathBuf {
+ let has_recommendations = |file: &PathBuf| recommendations::read_json(file).is_some_and(|value| value.get("recommendations").is_some());
+ let mut files = config::service::FOLDER_CONFIG_DIRS.iter().rev().map(|dir| folder.join(dir).join("extensions.json"));
+ files.find(has_recommendations).unwrap_or_else(|| config::service::folder_config_dir(folder).join("extensions.json"))
+}
+
+/// `addOrRemoveWorkspaceFolderRecommendation` and `addOrRemoveWorkspaceRecommendation` (`prefix` `extensions`):
+/// adding appends to `recommendations` and drops it from `unwantedRecommendations`; JSONEditingService creates a
+/// missing file.
+fn write_recommendation(file: &Path, prefix: &[&str], id: &str, add: bool) -> std::io::Result<()> {
+ let mut text = std::fs::read_to_string(file).unwrap_or_else(|_| "{}".into());
+ let value = recommendations::read_json(file).unwrap_or_default();
+ let config = prefix.iter().fold(&value, |value, key| &value[*key]);
+ let path = |key: &str, index: usize| prefix.iter().map(|key| Segment::Key((*key).into())).chain([Segment::Key(key.into()), Segment::Index(index)]).collect::<Vec<_>>();
+ let index_in = |key: &str| config[key].as_array().and_then(|ids| ids.iter().position(|entry| entry.as_str().is_some_and(|entry| entry.eq_ignore_ascii_case(id))));
+ let mut writes = Vec::new();
+ if add {
+ writes.push((path("recommendations", usize::MAX), Some(json!(id))));
+ writes.extend(index_in("unwantedRecommendations").map(|index| (path("unwantedRecommendations", index), None)));
+ } else {
+ writes.extend(index_in("recommendations").map(|index| (path("recommendations", index), None)));
+ }
+ if writes.is_empty() {
+ return Ok(());
+ }
+ let options = FormattingOptions { tab_size: 4, insert_spaces: false, eol: "\n".into() };
+ for (path, value) in writes {
+ let edits = set_property(&text, &path, value.as_ref(), &options);
+ text = apply_edits(&text, &edits);
+ }
+ if let Some(parent) = file.parent() {
+ std::fs::create_dir_all(parent)?;
+ }
+ std::fs::write(file, text)
+}
diff --git a/port/ledger.md b/port/ledger.md
index cacc5186ef9..8d094b76009 100644
--- a/port/ledger.md
+++ b/port/ledger.md
@@ -536,7 +536,7 @@ One row per upstream unit, generated by `bun port/tools/gen-ledger.ts`; mileston
| workbench/contrib/emergencyAlert | workbench contribution | | removed | | no AI or Microsoft services by decision (port/notes.md); API stays inert |
| workbench/contrib/emmet | workbench contribution | M13 | verified | | workbench/emmet.rs: Emmet: Expand Abbreviation (`emmet.expandAbbreviation` with the language at the cursor and the emmet parent mode of its grammar's scope, emmetAction.test.ts cases), Tab with `emmet.triggerExpansionOnTab`, the Edit menu entry: cargo test -p app emmet menubar |
| workbench/contrib/encryption | workbench contribution | M10 | n/a | | encryption.contribution.ts only migrates Linux `password-store` argv values to gnome-libsecret; the port runs on macOS and keeps secrets in the Keychain |
-| workbench/contrib/extensions | workbench contribution | M18 | ported | [3 M] extensions.contribution.ts: the `MenuId.ExtensionContext` items Auto Update (Publisher), Install (unsigned), Install (Do not Sync), Install Pre-Release (Do not Sync), Download VSIX, Download Pre-Release VSIX, Download Specific Version VSIX..., Account Preferences, Apply Extension to all Profiles, Sync This Extension and Add to/Remove from Workspace Recommendations wait for their commands (Show Pre-Release/Release Version belong to the extension editor's menu) | cargo test -p app extension the_manage_menu_lists_the_extension_context_menu the_manage_menu_installs_a_version_and_toggles_an_ignored_recommendation install_specific_version_installs_the_picked_version an_activated_extensions_row_shows_its_activation_time the_manage_menu_sets_a_theme_of_the_extension the_views_are_panes extension_bisect bisect_finds_the_extension_and_keeps_it_disabled extension_features the_runtime_status_lists_uncaught_errors_and_messages invalid_contributed static_entries_need_the_proposal group_needs_the_proposal debuggers_merge_by_type_and_keep_the_built_in_values skipped_menu_contributions_are_extension_messages contributed_command_messages invalid_views_and_view_containers_are_extension_messages invalid_configuration_is_an_extension_message invalid_json_validation_is_an_extension_message invalid_colors_and_icons_are_extension_messages invalid_semantic_token_contributions_are_extension_messages invalid_problem_patterns_and_matchers_are_extension_messages invalid_grammars_are_extension_messages invalid_notebook_contributions_are_extension_messages (extensionsViews, extensionQuery, extensionEnablementService tests); cargo test -p exthost all_compatible_versions_follow_the_kind_and_the_engine; ui-pair `menus/extension-context.json` with `--extensionDevelopmentPath=<repo>/port/fixtures/extensions/menus`, `menus/extension-theme.json`, port/fixtures/extensions/ui-view.json. Out with removed parts: Report Issue & Continue (contrib/issue), the authentication point (services/authentication) |
+| workbench/contrib/extensions | workbench contribution | M18 | ported | [3 M] extensions.contribution.ts: the `MenuId.ExtensionContext` item Apply Extension to all Profiles (`toggleApplyToAllProfiles`) waits for application-scoped extensions: extensionsScannerService.ts `scanExtensionsFromProfile` adds the default profile's `isApplicationScoped` entries to every other profile, exthost extension_management.rs `UserExtensions::scan` reads only the current profile's extensions.json; [3 S] the row's activation time in ui-pair `menus/extension-context.json`: languageService.ts `onDidRequestRichLanguageFeatures` sends `onLanguage` for every text model an editor widget asks features of, the view's SuggestEnabledInput search box (`createModel('', null)`) included, host_sync.rs only for open editor documents, so with no editor open the reference's Emmet row shows its activation time (34ms) and the port's none; Developer: Startup Performance lists the eager activations in both | cargo test -p app extension the_manage_menu_lists_the_extension_context_menu the_manage_menu_installs_a_version_and_toggles_an_ignored_recommendation the_manage_menu_auto_updates_a_publisher_and_toggles_a_workspace_recommendation download_specific_version_picks_a_version_then_a_folder install_specific_version_installs_the_picked_version an_activated_extensions_row_shows_its_activation_time the_manage_menu_sets_a_theme_of_the_extension the_views_are_panes extension_bisect bisect_finds_the_extension_and_keeps_it_disabled extension_features the_runtime_status_lists_uncaught_errors_and_messages invalid_contributed static_entries_need_the_proposal group_needs_the_proposal debuggers_merge_by_type_and_keep_the_built_in_values skipped_menu_contributions_are_extension_messages contributed_command_messages invalid_views_and_view_containers_are_extension_messages invalid_configuration_is_an_extension_message invalid_json_validation_is_an_extension_message invalid_colors_and_icons_are_extension_messages invalid_semantic_token_contributions_are_extension_messages invalid_problem_patterns_and_matchers_are_extension_messages invalid_grammars_are_extension_messages invalid_notebook_contributions_are_extension_messages (extensionsViews, extensionQuery, extensionEnablementService tests); cargo test -p exthost all_compatible_versions_follow_the_kind_and_the_engine all_versions_ignore_the_engine_but_not_the_block; ui-pair `menus/extension-context.json` with `--extensionDevelopmentPath=<repo>/port/fixtures/extensions/menus`, `menus/extension-theme.json`, port/fixtures/extensions/ui-view.json. Out with removed parts: Report Issue & Continue (contrib/issue), the authentication point and the Account Preferences item (services/authentication), the Install (Do not Sync), Install Pre-Release (Do not Sync) and Sync This Extension items (Settings Sync, no sign-in by decision, port/notes.md) |
| workbench/contrib/externalTerminal | workbench contribution | M15 | verified | | workbench/external_terminal.rs: Open New External Terminal (`workbench.action.terminal.openNativeConsole`, cmd+shift+c), with several workspace folders after the Select workspace folder pick (cargo test -p app open_native_console_picks_a_folder_in_a_multi_root_workspace); cargo test -p app external_terminal; ui-pair (port/results/terminal.md) |
| workbench/contrib/externalUriOpener | workbench contribution | M12 | verified | | workbench/opener.rs: externalUriOpenerService.ts getRequestedOpener (workbench.externalUriOpeners globs), chooseOpener, "How would you like to open: {0}" picker; no Simple Browser (out of scope); verified at port-m12b-verify: cargo test -p app opener 4/4; Simple Browser is out of scope by decision |
| workbench/contrib/files | workbench contribution | M12 | verified | | explorer.rs, dialog.rs, workbench/workspace_editing.rs, workbench/file_compare.rs: cargo test -p app explorer_actions file_actions view_state nest copy_path copied_path_labels compact get_context compressed_navigation explorer_find find_filters files_dropped_from_finder view_title_and_file_actions new_file_creates file_compare focus_view_commands files_that_do_not_resolve open_editors body_limits_clamp sticky pinned_editors tab_scroll tree_guides hover unpin_hover open_with_opens_the_resource the_context_menu_selects_the_row readonly_keys_follow_the_focused_item_and_its_parent a_failed_create_offers a_folder_dropped_on_the_root a_delete_confirmation_follows_the_dialog_style cmd_v_pastes_the_files_finder_copied dragging_a_root_reorders_the_workspace_folders compacts_single_child_folders_into_one_row a_workspace_root_that_fails_to_resolve_is_decorated_with_its_error a_copy_onto_a_dirty_model_reverts_it_to_the_copied_file an_unreadable_folder_expands_to_no_children (explorerFileNestingTrie.test.ts); ui-pair port/fixtures/ui-pair/m12/workspace-folders.json, port/fixtures/ui-pair/m12/compare-saved.json, m12/compare.json, m12/find-in-folder.json, m12/folder-terminal.json, m12/explorer-ops.json, m12/editor-placeholders.json, m12/open-editors.json, m12/tab-scroll.json, m12/explorer-guides.json, m12/pinned-tabs.json (port/results/contextmenu.md). Differences left (port/notes.md milestone 12): a long tooltip breaks one segment earlier (GPUI line wrapper), the pin action loses its hover after Cmd+W until the pointer moves, a shrink sticky tab with a badge has no room for its name. Virtual workspaces: milestone 25 |