refactor(completion): clean up popup scroll API
This commit is contained in:
@@ -135,15 +135,7 @@ function Popup:dispatch_resolve(client, item, ft, pum, word, buf)
|
||||
end
|
||||
end
|
||||
|
||||
---@param direction string single-line scroll keycode (<C-e> or <C-y>)
|
||||
function Popup:scroll_line(direction)
|
||||
self:scroll(direction, 1)
|
||||
end
|
||||
|
||||
---@param direction string
|
||||
function Popup:scroll_half(direction)
|
||||
self:scroll(direction, HALF_HEIGHT)
|
||||
end
|
||||
Popup.HALF_PAGE = HALF_HEIGHT
|
||||
|
||||
---@param content string
|
||||
---@param pum ow.lsp.completion.Pum
|
||||
@@ -209,14 +201,16 @@ function Popup:render(content, pum, width)
|
||||
self:update_indicators()
|
||||
end
|
||||
|
||||
---@param direction string
|
||||
---@param direction "up" | "down"
|
||||
---@param count integer
|
||||
function Popup:scroll(direction, count)
|
||||
if not self:is_visible() then
|
||||
return
|
||||
end
|
||||
local key = direction == "down" and vim.keycode("<C-e>")
|
||||
or vim.keycode("<C-y>")
|
||||
vim.api.nvim_win_call(self.winid, function()
|
||||
vim.cmd.normal({ args = { count .. direction }, bang = true })
|
||||
vim.cmd.normal({ args = { count .. key }, bang = true })
|
||||
end)
|
||||
self:update_indicators()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user