Skip to content

Commit

Permalink
fix(fold): cursor is incorrect with screenrow motions on folded line
Browse files Browse the repository at this point in the history
Fix #22232
  • Loading branch information
luukvbaal committed Feb 12, 2023
1 parent 5d3769e commit 49ab104
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/nvim/normal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2534,6 +2534,7 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist)
}
}

foldAdjustCursor(); // Adjust for when cursor has landed on a closed fold
if (virtual_active() && atend) {
coladvance(MAXCOL);
} else {
Expand Down
43 changes: 43 additions & 0 deletions test/functional/ui/fold_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1975,6 +1975,49 @@ describe("folded lines", function()
]])
end
end)

it('cursorline highlight is applied correctly with gj/gk', function()
funcs.setline(1, 'line 1')
funcs.setline(2, 'line 2')
funcs.setline(3, 'line 3')
funcs.setline(4, 'line 4')
command('set number cursorline')
feed("zfjjgk")
if multigrid then
screen:expect([[
## grid 1
[2:---------------------------------------------]|
[2:---------------------------------------------]|
[2:---------------------------------------------]|
[2:---------------------------------------------]|
[2:---------------------------------------------]|
[2:---------------------------------------------]|
[2:---------------------------------------------]|
[3:---------------------------------------------]|
## grid 2
{9: 1 }{12:^+-- 2 lines: line 1·····················}|
{8: 3 }line 3 |
{8: 4 }line 4 |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
## grid 3
|
]])
else
screen:expect([[
{9: 1 }{12:^+-- 2 lines: line 1·····················}|
{8: 3 }line 3 |
{8: 4 }line 4 |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
|
]])
end
end)
end

describe("with ext_multigrid", function()
Expand Down

0 comments on commit 49ab104

Please sign in to comment.