Skip to content

Commit 025698b

Browse files
Kaikacyibhagwan
authored andcommitted
improve builtin previewer scrolling
1 parent c6efab0 commit 025698b

2 files changed

Lines changed: 5 additions & 17 deletions

File tree

lua/fzf-lua/defaults.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ M.defaults = {
8484
list = false,
8585
foldenable = false,
8686
foldmethod = "manual",
87-
-- >0 to prevent scrolling issues (#500)
88-
scrolloff = 1,
87+
scrolloff = 0,
8988
},
9089
},
9190
-- on_create = function(_)

lua/fzf-lua/previewer/builtin.lua

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -509,16 +509,9 @@ function Previewer.base:scroll(direction)
509509
["half-page-down"] = ("%c"):format(0x04), -- [[]]
510510
["page-up"] = ("%c"):format(0x02), -- [[]]
511511
["page-down"] = ("%c"):format(0x06), -- [[]]
512-
-- ^Y/^E doesn't seem to work, "Mgk" also doesn't (#2111)
513-
-- TODO: Can't scroll above line 2?
514-
["line-up"] = (function()
515-
local wi = utils.getwininfo(preview_winid)
516-
return wi.topline <= 2 and "gg" or function()
517-
api.nvim_win_set_cursor(0, { wi.topline, 1 })
518-
vim.cmd("norm! gk")
519-
end
520-
end)(),
521-
["line-down"] = "Mgj",
512+
-- ^Y/^E doesn't seem to work
513+
["line-up"] = "Hgk",
514+
["line-down"] = "Lgj",
522515
["reset"] = true, -- dummy for exit condition
523516
})[direction]
524517

@@ -536,11 +529,7 @@ function Previewer.base:scroll(direction)
536529
end)
537530
else
538531
pcall(vim.api.nvim_win_call, preview_winid, function()
539-
if type(input) == "function" then
540-
input()
541-
else
542-
vim.cmd([[norm! ]] .. input)
543-
end
532+
vim.cmd([[norm! ]] .. input)
544533
-- `zb` at bottom?
545534
local wi = utils.getwininfo(preview_winid)
546535
if wi.height > (wi.botline - wi.topline) then

0 commit comments

Comments
 (0)