diff src/testdir/test_fold.vim @ 23687:09ad3f1b9714 v8.2.2385

patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold Commit: https://github.com/vim/vim/commit/e71996bd0865659bde5450f466bc3e53e83431b2 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jan 21 17:03:07 2021 +0100 patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold Problem: "gj" and "gk" do not work correctly when inside a fold. Solution: Move check for folding. (closes https://github.com/vim/vim/issues/7724, closes https://github.com/vim/vim/issues/4095)
author Bram Moolenaar <Bram@vim.org>
date Thu, 21 Jan 2021 17:15:04 +0100
parents ef4f890f02f6
children b6d8d9578375
line wrap: on
line diff
--- a/src/testdir/test_fold.vim
+++ b/src/testdir/test_fold.vim
@@ -859,4 +859,39 @@ func Test_fold_create_delete()
   bwipe!
 endfunc
 
+func Test_fold_relative_move()
+  enew!
+  set fdm=indent sw=2 wrap tw=80
+
+  let content = [ '  foo', '  bar', '  baz',
+              \   repeat('x', 100),
+              \   '  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('.')))
+  normal 2gk
+  call assert_equal(2, winline())
+
+  set fdm& sw& wrap& tw&
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab