mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-04 19:41:36 -05:00
Scripts: a Copy the run puts back leaves the clipboard as it was
edit.copy, artboard.copy and artboard.cut now have the clipboard saved before them, as edit.cut and command.batch do. Before, a Copy whose result could not reach the script was put back without its clipboard, so the copy stayed on the clipboard and the run reported copied: true.
This commit is contained in:
@@ -630,7 +630,7 @@ impl World {
|
||||
/// The commands that can change the clipboard and still fail, or still be put back because their
|
||||
/// result cannot reach the script, and that do not put it back themselves. The clipboard can hold
|
||||
/// a great deal, so a savepoint copies it only for these.
|
||||
const CAN_FAIL_AFTER_COPYING: &[&str] = &["action.batch", "command.batch", "edit.cut"];
|
||||
const CAN_FAIL_AFTER_COPYING: &[&str] = &["action.batch", "artboard.copy", "artboard.cut", "command.batch", "edit.copy", "edit.cut"];
|
||||
|
||||
/// The commands that remove a document's undo history, or the document: a savepoint keeps a whole
|
||||
/// copy of the histories for these. Any other command that removes or changes a step under the
|
||||
|
||||
@@ -521,11 +521,13 @@ fn a_copy_or_cut_the_run_puts_back_is_not_reported() {
|
||||
let r = run(
|
||||
&mut s,
|
||||
"try { vc.run('command.batch', {commands: [{command: 'edit.copy', params: {}}]}); } catch (e) { vc.log(e.name); }\
|
||||
try { vc.run('edit.cut'); } catch (e) { vc.log(e.name); }",
|
||||
try { vc.run('edit.cut'); } catch (e) { vc.log(e.name); }\
|
||||
try { vc.run('edit.copy'); } catch (e) { vc.log(e.name); }\
|
||||
try { vc.run('artboard.copy', {indices: [0]}); } catch (e) { vc.log(e.name); }",
|
||||
);
|
||||
crate::script::TEST_RESULT_BYTES.with(|b| b.set(None));
|
||||
let r = r.unwrap();
|
||||
assert_eq!(r["log"], json!(["RangeError", "RangeError"]), "{r}");
|
||||
assert_eq!(r["log"], json!(["RangeError", "RangeError", "RangeError", "RangeError"]), "{r}");
|
||||
assert_eq!(r.get("copied"), None, "{r}");
|
||||
assert_eq!(s.copies, copies);
|
||||
assert!(s.clipboard_copied);
|
||||
|
||||
Reference in New Issue
Block a user