Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed zz doesn't center the due to wrapped line #76

Merged
merged 7 commits into from
Jan 15, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixed scroll forever when cursor is at top or bottom
chomosuke committed Jul 28, 2022

Verified

This commit was created on github.com and signed with GitHub’s verified signature. The key has expired.
commit f9d65851484168c43c579f5df5a34856f4d8861b
5 changes: 4 additions & 1 deletion lua/neoscroll/init.lua
Original file line number Diff line number Diff line change
@@ -127,6 +127,7 @@ end
-- Scroll one line in the given direction
local function scroll_one_line(lines_to_scroll, scroll_window, scroll_cursor, data)
local winline_before = vim.fn.winline() -- record for later
local curpos_line_before = vim.fn.getcurpos()[2]
local scroll
local scrolled_lines
if lines_to_scroll > 0 then
@@ -143,7 +144,9 @@ local function scroll_one_line(lines_to_scroll, scroll_window, scroll_cursor, da
if lines_behind > 0 then
vim.cmd(scroll(data, false, scroll_cursor, lines_behind))
end
elseif scroll_window then
elseif curpos_line_before == vim.fn.getcurpos()[2] then
-- if curpos_line didn't change, we can check it to see if it scroll more
-- than it should due to wrapped line
scrolled_lines = winline_before - vim.fn.winline()
end
relative_line = relative_line + scrolled_lines