You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Arbitrarily renaming functions while transpiling breaks some scripting reference compatibility #5
I ran into this funny "gotcha" that is very subtle and could easily catch people off guard.
I'm working on a PS script that makes many changes to the document history, and I only want it to have a single history state change for the entire script. Photoshop has a function called suspendHistory which is defined in the JS Reference Guide as:
suspendHistory (historyString, javaScriptString)
Provides a single entry in history states for the entire script provided by javaScriptString. Allows a single undo for all actions taken in the script. The historyString parameter provides the string to use for the history state. The javaScriptString parameter provides a string of JavaScript code to execute while history is suspended.
However, this doesn't work, and main() never runs. After scratching my head for a few minutes debugging my script and double checking my implementation I realized that it is caused by the transpiler prepending underscores to function names which breaks references:
I'm not sure if renaming the functions during transpilation is necessary, but if it is, it would be nice to warn people of this behavior in the README so they don't get frustrated trying to figure out why basic code isn't working. This is a problem in any area where string references to functions are used.
Activity