Skip to content

Commit 19b209c

Browse files
committed
Fix above finding entry after cursor when col = 0
1 parent 1e322a9 commit 19b209c

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

lua/qf.lua

+2-5
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,6 @@ local function follow_prev(list, items, bufnr, line, col)
356356

357357
local valid = is_valid(item)
358358
if valid then
359-
last_valid = j
360359
-- We overshot the current buffer
361360
if found_buf and item.bufnr ~= bufnr then
362361
return j
@@ -365,7 +364,7 @@ local function follow_prev(list, items, bufnr, line, col)
365364
-- If the current entry is past cursor, of the entry of the cursor has been
366365
-- passed
367366
item.col = math.min(item.col, linelen(item.bufnr, item.lnum))
368-
if item.lnum < line or (item.lnum == line and col and item.col < col) then
367+
if item.lnum < line or (item.lnum == line and (item.col > 0 and col and item.col < col)) then
369368
return j
370369
end
371370
end
@@ -383,12 +382,10 @@ end
383382
-- Returns the first entry after the cursor in buf or the first entry in the
384383
-- buffer
385384
local function follow_next(list, items, bufnr, line, col)
386-
local last_valid = 1
387385
local found_buf = false
388386
for i, item in ipairs(items) do
389387
local valid = is_valid(item)
390388
if valid then
391-
last_valid = i
392389
-- We overshot the current buffer
393390
if found_buf and item.bufnr ~= bufnr then
394391
return i
@@ -397,7 +394,7 @@ local function follow_next(list, items, bufnr, line, col)
397394
-- If the current entry is past cursor, of the entry of the cursor has been
398395
-- passed
399396
item.col = math.min(item.col, linelen(item.bufnr, item.lnum))
400-
if item.lnum > line or (item.lnum == line and col and item.col > col) then
397+
if item.lnum > line or (item.lnum == line and (item.col > 0 and col and item.col > col)) then
401398
return i
402399
end
403400
end

0 commit comments

Comments
 (0)