mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-05 21:42:59 -05:00
Scripts: a grid view run after an edit adds no undo step, host names listed
A run that only showed the perspective grid or set its active plane added a Run Script undo step when the document already had an undo step, because the check compared the working copy's history with the document's own. The working copy starts with no undo steps, so the check now asks whether it holds any. The host name inventory lists the perspective grid enumerations and the new Application and Document members, including the setter rows of the members that are not available yet.
This commit is contained in:
1 parent
8b31227089
commit
7ac929f2e4
3 files changed
+30
-9
No files matched your search
@@ -2251,8 +2251,9 @@ impl Session {
|
||||
};
|
||||
// The perspective grid's view state changes without an undo step, as it does outside a
|
||||
// run, when no command in the run recorded an undo step of its own on the working copy.
|
||||
let (now, was) = (&st.history.undo, &b.history.undo);
|
||||
let recorded = now.len() != was.len() || !now.last().zip(was.last()).map_or(now.is_empty(), |(x, y)| Arc::ptr_eq(&x.doc, &y.doc));
|
||||
// The working copy starts with no undo steps (`World::working`), so any step it holds now
|
||||
// was recorded in the run.
|
||||
let recorded = !st.history.undo.is_empty();
|
||||
let changed = !st.same_content(&b.doc) && (recorded || !cmd::distortcmds::only_grid_view_changed(&st.doc, &b.doc));
|
||||
st.history = std::mem::take(&mut b.history);
|
||||
st.recovery.clone_from(&b.recovery);
|
||||
|
||||
@@ -61,6 +61,19 @@ fn grid_view_commands_in_a_run_add_no_undo_step_but_an_edit_still_does() {
|
||||
assert_eq!(grid(&mut s)["visible"], true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_grid_view_run_after_an_edit_adds_no_undo_step() {
|
||||
let mut s = doc();
|
||||
s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 10, "height": 10})).unwrap();
|
||||
let before = undo_steps(&s);
|
||||
let drawn = s.active().unwrap().doc.node_count();
|
||||
run(&mut s, "app.activeDocument.showPerspectiveGrid(); vc.run('perspective.plane.set', {plane: 'ground'});").unwrap();
|
||||
assert_eq!((grid(&mut s)["visible"].clone(), grid(&mut s)["plane"].clone()), (json!(true), json!("ground")));
|
||||
assert_eq!(undo_steps(&s), before);
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert_eq!(s.active().unwrap().doc.node_count(), drawn - 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_grid_edit_that_changes_only_view_fields_keeps_its_undo_step_in_a_run() {
|
||||
let mut s = doc();
|
||||
|
||||
@@ -42,7 +42,8 @@ const OUTSIDE: &[(&str, &str, &str)] = &[
|
||||
/// The names the host adds that stay inside the document and the run, by the object that has them.
|
||||
/// Reading a file or a folder, a file dialog and a message to the person do not change anything
|
||||
/// outside it. The document model (`app`, its classes and the enumerations) acts on the open
|
||||
/// documents; `Document.saveAs` and `close` throw "not available yet".
|
||||
/// documents; `Document.saveAs`, `close` and the perspective grid preset files, and the workspace
|
||||
/// methods, `loadColorSettings` and `showPresets` of `Application`, throw "not available yet".
|
||||
const INSIDE: &[(&str, &str)] = &[
|
||||
("", "$ File Folder alert confirm localize prompt toSource"),
|
||||
("Object.prototype.", "toSource"),
|
||||
@@ -75,14 +76,16 @@ const INSIDE: &[(&str, &str)] = &[
|
||||
"",
|
||||
"app Application Artboard Artboards CompoundPathItem CompoundPathItems CoordinateSystem Document \
|
||||
DocumentArtboardLayout DocumentColorSpace DocumentPresetType DocumentPreviewMode DocumentRasterResolution \
|
||||
DocumentTransparencyGrid Documents ElementPlacement GroupItem GroupItems Layer Layers PageItem PageItems RulerUnits \
|
||||
ZOrderMethod",
|
||||
DocumentTransparencyGrid Documents ElementPlacement GroupItem GroupItems Layer Layers PageItem PageItems \
|
||||
PerspectiveGridPlaneType PerspectiveGridType RulerUnits ZOrderMethod",
|
||||
),
|
||||
("Application.", "prototype"),
|
||||
(
|
||||
"Application.prototype.",
|
||||
"activeDocument activeDocument= beep beep= constructor coordinateSystem coordinateSystem= documents getIsFileOpen \
|
||||
selection typename",
|
||||
"activeDocument activeDocument= beep beep= constructor coordinateSystem coordinateSystem= deleteWorkspace \
|
||||
deleteWorkspace= documents getIsFileOpen getPresetSettings loadColorSettings loadColorSettings= resetWorkspace \
|
||||
resetWorkspace= saveWorkspace saveWorkspace= selection showPresets showPresets= switchWorkspace switchWorkspace= \
|
||||
typename",
|
||||
),
|
||||
("Documents.", "prototype"),
|
||||
("Documents.prototype.", "add addDocument constructor getByName index length parent typename"),
|
||||
@@ -90,8 +93,10 @@ const INSIDE: &[(&str, &str)] = &[
|
||||
(
|
||||
"Document.prototype.",
|
||||
"activeLayer activeLayer= artboards close close= compoundPathItems constructor convertCoordinate \
|
||||
documentColorSpace groupItems height layers name pageItems parent pathItems pathItems= rulerOrigin rulerOrigin= \
|
||||
rulerUnits saveAs saveAs= selection selection= swatches swatches= symbols symbols= textFrames textFrames= typename \
|
||||
documentColorSpace exportPerspectiveGridPreset exportPerspectiveGridPreset= getPerspectiveActivePlane groupItems \
|
||||
height hidePerspectiveGrid importPerspectiveGridPreset importPerspectiveGridPreset= layers name pageItems parent \
|
||||
pathItems pathItems= rulerOrigin rulerOrigin= rulerUnits saveAs saveAs= selectPerspectivePreset selection \
|
||||
selection= setActivePlane showPerspectiveGrid swatches swatches= symbols symbols= textFrames textFrames= typename \
|
||||
views views= width",
|
||||
),
|
||||
("Layer.", "prototype"),
|
||||
@@ -153,6 +158,8 @@ const INSIDE: &[(&str, &str)] = &[
|
||||
TransparencyGridNone TransparencyGridOrange TransparencyGridPurple TransparencyGridRed",
|
||||
),
|
||||
("ElementPlacement.", "INSIDE PLACEAFTER PLACEATBEGINNING PLACEATEND PLACEBEFORE"),
|
||||
("PerspectiveGridPlaneType.", "GRIDFLOORPLANETYPE GRIDLEFTPLANETYPE GRIDRIGHTPLANETYPE INVALIDGRIDPLANETYPE"),
|
||||
("PerspectiveGridType.", "InvalidPerspectiveGridType OnePointPerspectiveGridType ThreePointPerspectiveGridType TwoPointPerspectiveGridType"),
|
||||
("RulerUnits.", "Centimeters Inches Millimeters Picas Pixels Points Qs Unknown"),
|
||||
("ZOrderMethod.", "BRINGFORWARD BRINGTOFRONT SENDBACKWARD SENDTOBACK"),
|
||||
];
|
||||
|
||||
Reference in new issue
Block a user