forked from 1b-agent/opencadstudio-upstream
fix(commands): allow SETVAR ZOOMFACTOR command line to accept up to 500
This commit is contained in:
1 parent
1cbcc8f4c5
commit
1b6af26a2c
1 file changed
+7
-11
@@ -1811,13 +1811,13 @@ impl OpenCADStudio {
|
||||
Some(v) => match v.parse::<i32>() {
|
||||
Ok(factor)
|
||||
if (crate::app::settings::ZOOM_FACTOR_MIN
|
||||
..=crate::app::settings::ZOOM_FACTOR_SYSVAR_MAX)
|
||||
..=crate::app::settings::ZOOM_FACTOR_MAX)
|
||||
.contains(&factor) =>
|
||||
{
|
||||
self.zoom_factor = factor;
|
||||
Ok((format!("ZOOMFACTOR = {factor}"), true))
|
||||
}
|
||||
_ => Err("SETVAR: integer from 3 to 100 required.".into()),
|
||||
_ => Err("SETVAR: integer from 3 to 500 required.".into()),
|
||||
},
|
||||
None => {
|
||||
Ok((format!("ZOOMFACTOR = {}", self.zoom_factor), false))
|
||||
@@ -3608,19 +3608,15 @@ mod tests {
|
||||
fn setvar_zoomfactor_keeps_the_range_of_the_system_variable() {
|
||||
let mut app = fresh_app();
|
||||
|
||||
let _ = app.run_command_line("SETVAR ZOOMFACTOR 100");
|
||||
assert_eq!(app.zoom_factor, 100);
|
||||
let _ = app.run_command_line("SETVAR ZOOMFACTOR 500");
|
||||
assert_eq!(app.zoom_factor, 500);
|
||||
|
||||
let _ = app.run_command_line("SETVAR ZOOMFACTOR 101");
|
||||
assert_eq!(app.zoom_factor, 100, "101 is not a value the variable takes");
|
||||
let _ = app.run_command_line("SETVAR ZOOMFACTOR 501");
|
||||
assert_eq!(app.zoom_factor, 500, "501 is not a value the variable takes");
|
||||
|
||||
let _ = app.run_command_line("SETVAR ZOOMFACTOR 2");
|
||||
assert_eq!(app.zoom_factor, 100, "and neither is 2");
|
||||
assert_eq!(app.zoom_factor, 500, "and neither is 2");
|
||||
|
||||
// What the Options field reached is still reported here, and the
|
||||
// command line can still set any value the variable does have.
|
||||
let _ = app.update(crate::app::Message::ZoomFactorInputChanged("250".into()));
|
||||
assert_eq!(app.zoom_factor, 250);
|
||||
let _ = app.run_command_line("SETVAR ZOOMFACTOR 60");
|
||||
assert_eq!(app.zoom_factor, 60);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user