diff options
-rw-r--r-- | src/server/buffer.nim | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/server/buffer.nim b/src/server/buffer.nim index 3a458cc4..97acc8e2 100644 --- a/src/server/buffer.nim +++ b/src/server/buffer.nim @@ -412,6 +412,8 @@ proc findPrevLink*(buffer: Buffer, cursorx, cursory: int): tuple[x, y: int] {.pr for iy in countdown(ly - 1, 0): let line = buffer.lines[iy] i = line.formats.len - 1 + let oly = iy + let olx = lx while i >= 0: let format = line.formats[i] let nl = format.node.getClickable() @@ -419,6 +421,12 @@ proc findPrevLink*(buffer: Buffer, cursorx, cursory: int): tuple[x, y: int] {.pr ly = iy lx = format.pos dec i + if iy == oly and olx == lx: + # Assume multiline anchors are always placed on consecutive lines. + # This is not true, but otherwise we would have to loop through + # the entire document, which would be rather inefficient. TODO: find + # an efficient and correct way to do this. + break while i >= 0: let format = line.formats[i] |