mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-08 22:28:09 +00:00
Merge pull request #5137 from dotCooCoo/fix/vars-p16
Variables: Lock Variables' description names the refused import
This commit is contained in:
@@ -117,7 +117,8 @@ pub struct Variables {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub active_dataset: Option<String>,
|
||||
/// Lock Variables: while set, variables can't be defined, deleted or renamed. Objects can
|
||||
/// still be bound to them and unbound, and datasets still change and apply.
|
||||
/// still be bound to them and unbound, and datasets still change and apply, except that an
|
||||
/// import whose header would define a variable is refused.
|
||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||
pub locked: bool,
|
||||
}
|
||||
|
||||
@@ -647,7 +647,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Lock Variables",
|
||||
["Window", "Variables"],
|
||||
None,
|
||||
"{locked?: bool} lock or unlock the variables (default: toggle); saved with the document; a change is one undo step. While locked, variable.define, variable.delete, variable.rename, variable.make…Dynamic and a variable.loadLibrary that would delete or define a variable are refused; binding, unbinding and the dataset commands still run → {locked}",
|
||||
"{locked?: bool} lock or unlock the variables (default: toggle); saved with the document; a change is one undo step. While locked, variable.define, variable.delete, variable.rename, variable.make…Dynamic and a variable.loadLibrary that would delete or define a variable are refused; binding, unbinding and the dataset commands still run, except a dataset.import whose header would define a variable → {locked}",
|
||||
has_doc,
|
||||
lock
|
||||
),
|
||||
|
||||
@@ -409,7 +409,8 @@ fn make_dynamic_errors_name_the_command() {
|
||||
}
|
||||
|
||||
/// Lock Variables refuses defining, deleting and renaming variables, Make … Dynamic included,
|
||||
/// while binding, unbinding and the dataset commands still run.
|
||||
/// while binding, unbinding and the dataset commands still run (an import that would define a
|
||||
/// variable is refused; see `locked_variables_refuse_header_cells_that_define_variables`).
|
||||
#[test]
|
||||
fn locked_variables_refuse_new_deleted_and_renamed_variables() {
|
||||
let mut s = session();
|
||||
@@ -453,6 +454,14 @@ fn locked_variables_refuse_new_deleted_and_renamed_variables() {
|
||||
s.execute("variable.define", &json!({"name": "Other", "kind": "text"})).unwrap();
|
||||
}
|
||||
|
||||
/// `variable.lock`'s params text names the dataset command it refuses: an import whose header
|
||||
/// would define a variable.
|
||||
#[test]
|
||||
fn the_lock_params_text_names_the_refused_import() {
|
||||
let params = cmd::find_command("variable.lock").unwrap().params;
|
||||
assert!(params.contains("the dataset commands still run, except a dataset.import whose header would define a variable"), "{params}");
|
||||
}
|
||||
|
||||
/// Locking is an undo step only when it changes the state, and the lock is saved with the
|
||||
/// document: a file saved locked opens locked, and a file without the key opens unlocked.
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user