This failure is not Philip's fault. It looks like the issue is due to the way Nisus Writer incorrectly interprets the selection created by the macro:
Code: Select all
$insertPoint = TextSelection.new $cell.text, Range.new(0,0)
That generated selection should always be a text insertion point, no matter what. However, if the targeted table cell is empty the text selection is promoted to a full cell selection– a table selection. That distinction doesn't normally matter, but with such a selection in place the macro's paste operation inserts the row(s) at the wrong location, one row too far down, and thus there's no change in content.
There's a few ways we might work around this problem. The macro could instead generate a selection that's one row earlier, like so:
Code: Select all
If $insertRow.location > 0
$selectRowRange = Range.new $insertRow.location - 1, 1
$insertPoint = TableSelection.new $sel.table, $selectRowRange
End
But as the "If" statement's location check may reveal, this only works when you don't need to move rows to the very top of the table.
A complete workaround could instead insert a placeholder character into the empty cell, so the proper text selection is always generated by the macro. Once the macro finishes moving the table rows, the temporary placeholder can be excised. I'll attach an amended macro that uses this strategy. I'll also file a bug report that we should fix this macro selection behavior.
Thanks!