mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Problem: "gj" in a closed fold does not move out of the fold. (Marco Hinz) Solution: Add a check for being in a closed fold. (closes #8062)
This commit is contained in:
12
src/normal.c
12
src/normal.c
@@ -2564,7 +2564,11 @@ nv_screengo(oparg_T *oap, int dir, long dist)
|
|||||||
{
|
{
|
||||||
if (dir == BACKWARD)
|
if (dir == BACKWARD)
|
||||||
{
|
{
|
||||||
if ((long)curwin->w_curswant >= width1)
|
if ((long)curwin->w_curswant >= width1
|
||||||
|
#ifdef FEAT_FOLDING
|
||||||
|
&& !hasFolding(curwin->w_cursor.lnum, NULL, NULL)
|
||||||
|
#endif
|
||||||
|
)
|
||||||
// Move back within the line. This can give a negative value
|
// Move back within the line. This can give a negative value
|
||||||
// for w_curswant if width1 < width2 (with cpoptions+=n),
|
// for w_curswant if width1 < width2 (with cpoptions+=n),
|
||||||
// which will get clipped to column 0.
|
// which will get clipped to column 0.
|
||||||
@@ -2598,7 +2602,11 @@ nv_screengo(oparg_T *oap, int dir, long dist)
|
|||||||
n = ((linelen - width1 - 1) / width2 + 1) * width2 + width1;
|
n = ((linelen - width1 - 1) / width2 + 1) * width2 + width1;
|
||||||
else
|
else
|
||||||
n = width1;
|
n = width1;
|
||||||
if (curwin->w_curswant + width2 < (colnr_T)n)
|
if (curwin->w_curswant + width2 < (colnr_T)n
|
||||||
|
#ifdef FEAT_FOLDING
|
||||||
|
&& !hasFolding(curwin->w_cursor.lnum, NULL, NULL)
|
||||||
|
#endif
|
||||||
|
)
|
||||||
// move forward within line
|
// move forward within line
|
||||||
curwin->w_curswant += width2;
|
curwin->w_curswant += width2;
|
||||||
else
|
else
|
||||||
|
@@ -890,28 +890,33 @@ func Test_fold_relative_move()
|
|||||||
new
|
new
|
||||||
set fdm=indent sw=2 wrap tw=80
|
set fdm=indent sw=2 wrap tw=80
|
||||||
|
|
||||||
let content = [ ' foo', ' bar', ' baz',
|
let longtext = repeat('x', &columns + 1)
|
||||||
\ repeat('x', &columns + 1),
|
let content = [ ' foo', ' ' .. longtext, ' baz',
|
||||||
\ ' foo', ' bar', ' baz'
|
\ longtext,
|
||||||
|
\ ' foo', ' ' .. longtext, ' baz'
|
||||||
\ ]
|
\ ]
|
||||||
call append(0, content)
|
call append(0, content)
|
||||||
|
|
||||||
normal zM
|
normal zM
|
||||||
|
|
||||||
call cursor(3, 1)
|
for lnum in range(1, 3)
|
||||||
call assert_true(foldclosed(line('.')))
|
call cursor(lnum, 1)
|
||||||
normal gj
|
call assert_true(foldclosed(line('.')))
|
||||||
call assert_equal(2, winline())
|
normal gj
|
||||||
|
call assert_equal(2, winline())
|
||||||
|
endfor
|
||||||
|
|
||||||
call cursor(2, 1)
|
call cursor(2, 1)
|
||||||
call assert_true(foldclosed(line('.')))
|
call assert_true(foldclosed(line('.')))
|
||||||
normal 2gj
|
normal 2gj
|
||||||
call assert_equal(3, winline())
|
call assert_equal(3, winline())
|
||||||
|
|
||||||
call cursor(5, 1)
|
for lnum in range(5, 7)
|
||||||
call assert_true(foldclosed(line('.')))
|
call cursor(lnum, 1)
|
||||||
normal gk
|
call assert_true(foldclosed(line('.')))
|
||||||
call assert_equal(3, winline())
|
normal gk
|
||||||
|
call assert_equal(3, winline())
|
||||||
|
endfor
|
||||||
|
|
||||||
call cursor(6, 1)
|
call cursor(6, 1)
|
||||||
call assert_true(foldclosed(line('.')))
|
call assert_true(foldclosed(line('.')))
|
||||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2711,
|
||||||
/**/
|
/**/
|
||||||
2710,
|
2710,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user