Fix jumping between definitions in the same buffer.

Fixes #632. See also a simpler alternative fix in the comments of that issue.