mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-11 22:22:25 +00:00
Plug-ins: setting the plug-ins folder again after clearing it installs its plug-ins
Clearing Preferences > Plug-ins & Scratch Disks > Additional Plug-ins Folder left the folder recorded as the one last loaded. Setting the same folder again then matched that record, and nothing in it was installed, so a plug-in removed in the meantime stayed removed. Clearing the preference now forgets the folder when it is the one last loaded.
This commit is contained in:
@@ -846,6 +846,15 @@ pub(crate) fn sync_prefs(s: &Session) {
|
||||
*last = Some((folder.to_string(), s.plugin_dir.clone(), load_folder(s, folder)));
|
||||
}
|
||||
|
||||
/// The Additional Plug-ins Folder preference was cleared from `old`: when `old` is the folder last
|
||||
/// loaded, it is forgotten, so setting the preference to it again loads it again.
|
||||
pub(crate) fn forget_prefs_folder(old: &str) {
|
||||
let mut last = FOLDER.lock().unwrap_or_else(|e| e.into_inner());
|
||||
if last.as_ref().is_some_and(|(f, _, _)| f == old.trim()) {
|
||||
*last = None;
|
||||
}
|
||||
}
|
||||
|
||||
/// Turns Safe Mode on for `--safe-mode`, before the plug-in folder is attached: no plug-in loads or
|
||||
/// runs in this process from then on.
|
||||
pub fn start_in_safe_mode() {
|
||||
|
||||
@@ -697,6 +697,9 @@ impl Session {
|
||||
let history_changed = p.history_states != self.prefs.history_states;
|
||||
let tile_edge_changed = p.pattern_tile_edge_color != self.prefs.pattern_tile_edge_color;
|
||||
let fonts_folder_changed = p.fonts_folder != self.prefs.fonts_folder;
|
||||
if p.plugins_folder.trim().is_empty() && !self.prefs.plugins_folder.trim().is_empty() {
|
||||
super::plugin::forget_prefs_folder(&self.prefs.plugins_folder);
|
||||
}
|
||||
let hyphen_exceptions_changed = p.hyphenation_exceptions != self.prefs.hyphenation_exceptions;
|
||||
let corner_radius_changed = p.corner_radius != self.prefs.corner_radius;
|
||||
let lock_guides_changed = p.lock_guides_by_default != self.prefs.lock_guides_by_default;
|
||||
|
||||
@@ -1315,6 +1315,25 @@ fn plugin_management_commands() {
|
||||
std::fs::remove_dir_all(&dir).ok();
|
||||
}
|
||||
|
||||
/// Clearing the Additional Plug-ins Folder forgets the folder: setting the same folder again
|
||||
/// installs what is in it, as setting any other folder does.
|
||||
#[test]
|
||||
fn plugins_folder_set_again_after_clearing_installs_its_plugins() {
|
||||
let dir = crate::tests_links::Folder::new("plugin-folder-cleared");
|
||||
let id = "test.engine.foldercleared";
|
||||
let src = tpl::returning(&tpl::manifest(id, "filter", "{}"), r#"{"objects":[]}"#);
|
||||
std::fs::write(dir.0.join("cleared.wasm"), wat::parse_str(src).unwrap()).unwrap();
|
||||
let mut s = session();
|
||||
let folder = json!({"key": "pluginsFolder", "value": dir.0.display().to_string()});
|
||||
run(&mut s, "prefs.set", folder.clone());
|
||||
assert!(vectorcraft_plugins::registry::get(id).is_some(), "installed from the folder");
|
||||
run(&mut s, "plugin.remove", json!({"id": id}));
|
||||
run(&mut s, "prefs.set", json!({"key": "pluginsFolder", "value": ""}));
|
||||
run(&mut s, "prefs.set", folder);
|
||||
assert!(vectorcraft_plugins::registry::get(id).is_some(), "installed again when the folder is set again");
|
||||
run(&mut s, "plugin.remove", json!({"id": id}));
|
||||
}
|
||||
|
||||
/// #2541: a plug-in installed in a session with a plug-in store is installed again in the next
|
||||
/// session that attaches the store, and Remove Plug-in takes it out of the store.
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user