To: vim_dev@googlegroups.com Subject: Patch 8.2.2711 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2711 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) Files: src/normal.c, src/testdir/test_fold.vim *** ../vim-8.2.2710/src/normal.c 2021-02-23 19:39:16.761841193 +0100 --- src/normal.c 2021-04-04 21:25:11.708675605 +0200 *************** *** 2564,2570 **** { if (dir == BACKWARD) { ! if ((long)curwin->w_curswant >= width1) // Move back within the line. This can give a negative value // for w_curswant if width1 < width2 (with cpoptions+=n), // which will get clipped to column 0. --- 2564,2574 ---- { if (dir == BACKWARD) { ! 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 // for w_curswant if width1 < width2 (with cpoptions+=n), // which will get clipped to column 0. *************** *** 2598,2604 **** n = ((linelen - width1 - 1) / width2 + 1) * width2 + width1; else n = width1; ! if (curwin->w_curswant + width2 < (colnr_T)n) // move forward within line curwin->w_curswant += width2; else --- 2602,2612 ---- n = ((linelen - width1 - 1) / width2 + 1) * width2 + width1; else n = width1; ! if (curwin->w_curswant + width2 < (colnr_T)n ! #ifdef FEAT_FOLDING ! && !hasFolding(curwin->w_cursor.lnum, NULL, NULL) ! #endif ! ) // move forward within line curwin->w_curswant += width2; else *** ../vim-8.2.2710/src/testdir/test_fold.vim 2021-04-01 13:39:47.504992915 +0200 --- src/testdir/test_fold.vim 2021-04-04 21:23:24.212902447 +0200 *************** *** 890,917 **** new set fdm=indent sw=2 wrap tw=80 ! let content = [ ' foo', ' bar', ' baz', ! \ repeat('x', &columns + 1), ! \ ' foo', ' bar', ' baz' \ ] call append(0, content) normal zM ! call cursor(3, 1) ! call assert_true(foldclosed(line('.'))) ! normal gj ! call assert_equal(2, winline()) call cursor(2, 1) call assert_true(foldclosed(line('.'))) normal 2gj call assert_equal(3, winline()) ! call cursor(5, 1) ! call assert_true(foldclosed(line('.'))) ! normal gk ! call assert_equal(3, winline()) call cursor(6, 1) call assert_true(foldclosed(line('.'))) --- 890,922 ---- new set fdm=indent sw=2 wrap tw=80 ! let longtext = repeat('x', &columns + 1) ! let content = [ ' foo', ' ' .. longtext, ' baz', ! \ longtext, ! \ ' foo', ' ' .. longtext, ' baz' \ ] call append(0, content) normal zM ! for lnum in range(1, 3) ! call cursor(lnum, 1) ! call assert_true(foldclosed(line('.'))) ! normal gj ! call assert_equal(2, winline()) ! endfor call cursor(2, 1) call assert_true(foldclosed(line('.'))) normal 2gj call assert_equal(3, winline()) ! for lnum in range(5, 7) ! call cursor(lnum, 1) ! call assert_true(foldclosed(line('.'))) ! normal gk ! call assert_equal(3, winline()) ! endfor call cursor(6, 1) call assert_true(foldclosed(line('.'))) *** ../vim-8.2.2710/src/version.c 2021-04-04 20:49:46.626430253 +0200 --- src/version.c 2021-04-04 21:25:46.924599293 +0200 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2711, /**/ -- Be thankful to be in a traffic jam, because it means you own a car. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///