Mercurial > vim
diff src/normal.c @ 31984:479c93ad4a3b v9.0.1324
patch 9.0.1324: "gj" and "gk" do not move correctly over a closed fold
Commit: https://github.com/vim/vim/commit/441a7a94482f704b66253b8d08130f27b6b13736
Author: Luuk van Baal <luukvbaal@gmail.com>
Date: Sat Feb 18 20:15:44 2023 +0000
patch 9.0.1324: "gj" and "gk" do not move correctly over a closed fold
Problem: "gj" and "gk" do not move correctly over a closed fold.
Solution: Use the same code as used for "j"/"k" to go to the next/previous
line. (Luuk van Baal, closes #12007)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 18 Feb 2023 21:30:03 +0100 |
parents | d8fdafc4b390 |
children | 4545f58c8490 |
line wrap: on
line diff
--- a/src/normal.c +++ b/src/normal.c @@ -2344,20 +2344,11 @@ nv_screengo(oparg_T *oap, int dir, long else { // to previous line -#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. - if (!(fdo_flags & FDO_ALL)) - (void)hasFolding(curwin->w_cursor.lnum, - &curwin->w_cursor.lnum, NULL); -#endif - if (curwin->w_cursor.lnum == 1) + if (!cursor_up_inner(curwin, 1)) { retval = FAIL; break; } - --curwin->w_cursor.lnum; - linelen = linetabsize_str(ml_get_curline()); if (linelen > width1) curwin->w_curswant += (((linelen - width1 - 1) / width2) @@ -2380,17 +2371,11 @@ nv_screengo(oparg_T *oap, int dir, long else { // to next line -#ifdef FEAT_FOLDING - // Move to the end of a closed fold. - (void)hasFolding(curwin->w_cursor.lnum, NULL, - &curwin->w_cursor.lnum); -#endif - if (curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count) + if (!cursor_down_inner(curwin, 1)) { retval = FAIL; break; } - curwin->w_cursor.lnum++; curwin->w_curswant %= width2; // Check if the cursor has moved below the number display // when width1 < width2 (with cpoptions+=n). Subtract width2