diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-01-21 17:03:07 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-01-21 17:03:07 +0100 |
commit | e71996bd0865659bde5450f466bc3e53e83431b2 (patch) | |
tree | fe75fc9ed0da7b204c44b0447fec13b3896b2809 /src/normal.c | |
parent | 5e6a7aa2b26077775906eb8411952dc6259694de (diff) | |
download | vim-git-e71996bd0865659bde5450f466bc3e53e83431b2.tar.gz |
patch 8.2.2385: "gj" and "gk" do not work correctly when inside a foldv8.2.2385
Problem: "gj" and "gk" do not work correctly when inside a fold.
Solution: Move check for folding. (closes #7724, closes #4095)
Diffstat (limited to 'src/normal.c')
-rw-r--r-- | src/normal.c | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/src/normal.c b/src/normal.c index a5f5794c5..c70971f8e 100644 --- a/src/normal.c +++ b/src/normal.c @@ -2570,12 +2570,6 @@ nv_screengo(oparg_T *oap, int dir, long dist) else { // to previous line - if (curwin->w_cursor.lnum == 1) - { - retval = FAIL; - break; - } - --curwin->w_cursor.lnum; #ifdef FEAT_FOLDING // Move to the start of a closed fold. Don't do that when // 'foldopen' contains "all": it will open in a moment. @@ -2583,6 +2577,13 @@ nv_screengo(oparg_T *oap, int dir, long dist) (void)hasFolding(curwin->w_cursor.lnum, &curwin->w_cursor.lnum, NULL); #endif + if (curwin->w_cursor.lnum == 1) + { + retval = FAIL; + break; + } + --curwin->w_cursor.lnum; + linelen = linetabsize(ml_get_curline()); if (linelen > width1) curwin->w_curswant += (((linelen - width1 - 1) / width2) @@ -5957,13 +5958,8 @@ nv_g_cmd(cmdarg_T *cap) */ case 'j': case K_DOWN: - // with 'nowrap' it works just like the normal "j" command; also when - // in a closed fold - if (!curwin->w_p_wrap -#ifdef FEAT_FOLDING - || hasFolding(curwin->w_cursor.lnum, NULL, NULL) -#endif - ) + // with 'nowrap' it works just like the normal "j" command. + if (!curwin->w_p_wrap) { oap->motion_type = MLINE; i = cursor_down(cap->count1, oap->op_type == OP_NOP); @@ -5976,13 +5972,8 @@ nv_g_cmd(cmdarg_T *cap) case 'k': case K_UP: - // with 'nowrap' it works just like the normal "k" command; also when - // in a closed fold - if (!curwin->w_p_wrap -#ifdef FEAT_FOLDING - || hasFolding(curwin->w_cursor.lnum, NULL, NULL) -#endif - ) + // with 'nowrap' it works just like the normal "k" command. + if (!curwin->w_p_wrap) { oap->motion_type = MLINE; i = cursor_up(cap->count1, oap->op_type == OP_NOP); |