Skip to content

Commit

Permalink
fix: disable scrolloff opt before positioning preview (fixes #45)
Browse files Browse the repository at this point in the history
  • Loading branch information
DNLHC committed Mar 29, 2023
1 parent bbded06 commit eb450d6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lua/glance/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,9 @@ function Glance:scroll_into_view(winnr, position)
return 0
end

local scrolloff_value = vim.wo.scrolloff
vim.wo.scrolloff = 0

-- Scroll the window down until we have enough rows to render the preview window.
-- Needs to be done row by row because the <C-e> command scrolls over lines and not rows
-- some lines can take more than 1 row when 'wrap' is enabled
Expand All @@ -382,6 +385,8 @@ function Glance:scroll_into_view(winnr, position)
row = vim.fn.winline()
end

vim.wo.scrolloff = scrolloff_value

return row
end

Expand Down

0 comments on commit eb450d6

Please sign in to comment.