clang-format: Refactor calculation of lines intersecting with -lines.

No functional changes intended. However, it seems to have found a buggy
behavior in one of the tests. I think this structure is generally
desirable and it will make a planned bugfix significantly easier.