Skip to content

Commit 96d0aeb

Browse files
Zwlin98ibhagwan
authored andcommitted
feat(buffers|blines): support search specified range of current buffer
1 parent caee132 commit 96d0aeb

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lua/fzf-lua/providers/buffers.lua

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,17 +312,23 @@ M.buffer_lines = function(opts)
312312
return bname, bicon and bicon .. utils.nbsp or nil
313313
end)()
314314

315-
local offset, lines = 0, #data
316-
if opts.current_buffer_only and opts.start == "cursor" then
317-
-- start display from current line and wrap from bottom (#822)
318-
offset = core.CTX().cursor[1] - 1
315+
local offset, start_line, end_line, lines = 0, 1, #data, #data
316+
if opts.current_buffer_only then
317+
start_line = opts.start_line or 1
318+
end_line = opts.end_line or end_line
319+
lines = end_line - start_line + 1
320+
if opts.start == "cursor" then
321+
-- start display from current line and wrap from bottom (#822)
322+
offset = core.CTX().cursor[1] - start_line
323+
end
319324
end
320325

321326
for i = 1, lines do
322327
local lnum = i + offset
323328
if lnum > lines then
324329
lnum = lnum % lines
325330
end
331+
lnum = lnum + start_line - 1
326332

327333
-- NOTE: Space after `lnum` is U+00A0 (decimal: 160)
328334
add_entry(string.format("[%s]\t%s\t%s%s\t%s \t%s",

0 commit comments

Comments
 (0)