fix(options): 'scrolloffpad' reads the wrong window #41684

Problem:
`get_scrolloffpad_value()` takes a window, but its else branch reads
`curwin->w_p_sop` instead of `wp->w_p_sop`.

Reachable from Vimscript, since `line('w0', winid)` runs
`update_topline()` on another window without making it current.

Solution:
Read the option from the window that was passed in.

AI-assisted
This commit is contained in:
Volodymyr Chernetskyi
2026-09-05 19:36:14 +02:00
committed by GitHub
parent 455b6a810c
commit 050fa30632
2 changed files with 18 additions and 1 deletions

View File

@@ -1599,6 +1599,23 @@ describe('scrolloffpad', function()
exec('normal! G')
screen:expect(s1)
end)
it("uses the target window's value, not the current window's", function()
exec([[
set scrolloff=10 scrolloffpad=0
enew!
call setline(1, map(range(1, 100), 'printf("line %d", v:val)'))
split
setlocal scrolloffpad=5
normal! G
wincmd j
silent 1,60d
]])
-- The upper window turned 'scrolloffpad' on for itself, so its own value
-- decides how far its cursor is padded from the end of the buffer, even
-- though the current window leaves the option at the global 0.
t.eq(36, n.fn.line('w0', n.fn.win_getid(1)))
end)
end)
describe('scroll_cursor_halfway()', function()