Fix bug in measuring of lines with only collapsed elements

Closes #1559