From f8e0dfe54cf364cab87d8ce3a2488c0c5292c977 Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Mon, 13 Apr 2026 20:14:41 -0600 Subject: [PATCH] feat: prioritize jump labels by distance from cursor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit scan() returns matches in top-to-bottom reading order. With the 26-label cap, that meant the first 26 matches on screen ate all the labels — your cursor could be at the bottom of the buffer and still have no labels near it. Sort matches by |line - cursor_line|, then by |col - cursor_col| as tie-break, before label assignment. Labels now land on the 26 closest matches rather than the 26 topmost. Same label pool, same public API, big UX win for any buffer with more hits than labels. --- lua/tiny-jump/init.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lua/tiny-jump/init.lua b/lua/tiny-jump/init.lua index 1df887e..0036a1c 100644 --- a/lua/tiny-jump/init.lua +++ b/lua/tiny-jump/init.lua @@ -102,6 +102,15 @@ function M.start() if #chars > 0 then local matches, avail = scan(chars, lines, top) + local cr = api.nvim_win_get_cursor(win) + local cl, cc = cr[1] - 1, cr[2] + table.sort(matches, function(a, b) + local da, db = math.abs(a.line - cl), math.abs(b.line - cl) + if da ~= db then + return da < db + end + return math.abs(a.start_col - cc) < math.abs(b.start_col - cc) + end) local li = 1 for _, m in ipairs(matches) do vim.hl.range(