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:
dotCooCoo
2026-11-22 11:58:38 -08:00
parent 41625f2c88
commit dc569257e1
2 changed files with 5 additions and 3 deletions
+1 -1
View File
@@ -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
+4 -2
View File
@@ -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);