Skip to content

Commit 359dd7d

Browse files
committed
fix(actions): set lnum=0 + valid=1 in sel_to_qf
For any qf entry with/without lnum, `:cnext` don't respect `:h restore-cursor`. With lnum=0, user can rewrite `:cnext` in script to custom the jump behavior, since this is a file entry. `valid=1` to make sure `:cfdo` can work as expected (#1560). e.g. #2592 (comment)
1 parent 29ee11c commit 359dd7d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lua/fzf-lua/actions.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,8 @@ local sel_to_qf = function(selected, opts, is_loclist)
314314
table.insert(qf_list, {
315315
bufnr = file.bufnr,
316316
filename = file.bufname or file.path or file.uri,
317-
lnum = file.line > 0 and file.line or 1,
317+
lnum = file.line or 0,
318+
valid = 1,
318319
col = file.col,
319320
text = text,
320321
})

lua/fzf-lua/profiles/cli.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,9 @@ return {
133133
local text = e.stripped:match(":%d+:%d?%d?%d?%d?:?(.*)$") or ""
134134
table.insert(qf_items, {
135135
filename = e.path,
136-
lnum = math.max(1, e.line or 1),
137-
col = math.max(1, e.col or 1),
136+
lnum = e.line or 0,
137+
col = e.col or 0,
138+
valid = 1,
138139
text = text,
139140
})
140141
end

0 commit comments

Comments
 (0)