1. delete some nodes
2. run the script to see the ghost selection
3. note "selection is good" does not print
Code: Select all
// Execute
// Called to execute the command
function Execute(params)
{
if(!Node.Selection()) return;
System.Trace(Node.Selection());
var selCount = Node.SelectedCount();
if(selCount == 0) return;
System.Trace(selCount);
System.Trace(Node.FirstSelected());
if(!IsValidSelection(Node.Selection())) return;
System.Trace("selection is good");
}
function IsValidSelection(selection)
{
if(!selection) return false;
var reWhiteSpace = /^\s/; // whitespace in first character position for cleaning selection text
var selectionArray = selection.split(";");
for(var i = 0; i < selectionArray.length; i++) {
var selClean = selectionArray[i].replace(reWhiteSpace, "");
if(!Node.Exists(selClean)) return false;
}
return true;
}