Fix the long distance path parser

Fixes the bug described in #1239.