Photoshop CC 2018 Freezes When Running Scripts
I have two simple scripts that split one text layer into multiple text layers. One creates a new text object for every character, one creates a new text object for every word (characters separated by a space). These scripts functioned as intended in previous versions of Photoshop. With the 2018 update, Photoshop will sometimes lock up when I use these scripts, necessitating a force close with Task Manager.
Here is an example. Text layer before script:
Text layers after script (intended):
Text later after script (Photoshop freezes):
When Photoshop freezes, toolbar, menu, and tool buttons can be clicked, but do not do anything. The layer panel is completely frozen, which I think might be related to the cause. Text becomes selected, cannot be unselected. No layers are created, the base layer is just edited. This issue does not always occur; it seems more likely to happen the longer Photoshop has been open.
Was something changed in the 2018 update with regard to scripting? If so, what do I have to change to fix my script? Or is there some problem with Photoshop itself?
Here is the script being used:
doc = app.activeDocument;
layer = doc.activeLayer;
var text = layer.textItem.contents;
var textArray = text.split(" ") || text.split("/r");
var pos = layer.textItem.position;
var sze = layer.textItem.size;
var DPI = app.activeDocument.resolution;
layer.textItem.contents = textArray[0];
layer.name = textArray[0];
for (var k=1; k<textArray.length; k++){
tmp = layer.duplicate();
tmp.textItem.position = [pos[0]+(Number(sze)*Number(DPI)*k*.015), pos[1]];
tmp.textItem.contents = textArray
; }
