Skip to content

Commit

Permalink
fix(utils/window): some of-by-one errors with scorlling
Browse files Browse the repository at this point in the history
fixes #104
  • Loading branch information
max397574 committed Oct 20, 2024
1 parent bffe11b commit b3acce0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lua/care/utils/window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,14 @@ end
function Window:scroll(delta)
self.current_scroll = self.current_scroll + delta
local win_data = self:get_data()
self.current_scroll = math.max(self.current_scroll, 2)
self.current_scroll = math.min(self.current_scroll, win_data.total_lines - win_data.height_without_border + 2)
self.current_scroll = math.max(self.current_scroll, 1)
self.current_scroll = math.min(self.current_scroll, win_data.total_lines - win_data.height_without_border + 1)

vim.api.nvim_win_call(self.winnr, function()
vim.cmd("normal! gg0")
vim.cmd("normal! " .. vim.keycode(string.rep("<c-e>", (self.current_scroll - 1))))
if self.current_scroll > 1 then
vim.cmd("normal! " .. vim.keycode(string.rep("<c-e>", (self.current_scroll - 1))))
end
end)
end

Expand Down

0 comments on commit b3acce0

Please sign in to comment.