.. Just one tiny point: InDesign will break a line after a @ sign without adding a hyphen, so the script gets a false result with a line ending in @.
Gosh. So it does! Not a day goes by without some unexpected behavior from our favourite desktop software
It seems Teus & Peter check each character where ID would have broken a word by itself (the code \u00AD, for example, is the manually inserted discretionary hyphen).
This quickee seems to work for one-offs:
but I have no idea about its performance in the long run.
Ariel -- Yes, that's right: if a line does not end in one of the characters in the list, then that line end in a broken word. Lines that do not end in a broken word have a space at the end (or a \00AD. \r, etc.). To count lines ending in @ as non-broken, indeed just add @ to the list.
Jongware: You could make the script work with app.selection.words[-1].lines.length, and we tried that for a comparison. It's unbelievably slow in large texts.