]> granicus.if.org Git - vim/commitdiff
patch 8.1.0024: % command not testded on #ifdef and comment v8.1.0024
authorBram Moolenaar <Bram@vim.org>
Sat, 26 May 2018 16:39:32 +0000 (18:39 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 26 May 2018 16:39:32 +0000 (18:39 +0200)
Problem:    % command not testded on #ifdef and comment.
Solution:   Add tests. (Dominique Pelle, closes #2956)

src/testdir/test_goto.vim
src/version.c

index ea67fe738606fb9bfe7ab34eb1c8b183867b27a4..c0235b170755ac0a28a8c9f6ae6dbff3e4876d20 100644 (file)
@@ -309,3 +309,65 @@ func Test_gd_local_block()
   \ ]
   call XTest_goto_decl('1gd', lines, 11, 11)
 endfunc
+
+func Test_motion_if_elif_else_endif()
+  new
+  a
+/* Test pressing % on #if, #else #elsif and #endif,
+ * with nested #if
+ */
+#if FOO
+/* ... */
+#  if BAR
+/* ... */
+#  endif
+#elif BAR
+/* ... */
+#else
+/* ... */
+#endif
+.
+  /#if FOO
+  norm %
+  call assert_equal([9, 1], getpos('.')[1:2])
+  norm %
+  call assert_equal([11, 1], getpos('.')[1:2])
+  norm %
+  call assert_equal([13, 1], getpos('.')[1:2])
+  norm %
+  call assert_equal([4, 1], getpos('.')[1:2])
+  /#  if BAR
+  norm $%
+  call assert_equal([8, 1], getpos('.')[1:2])
+  norm $%
+  call assert_equal([6, 1], getpos('.')[1:2])
+
+  bw!
+endfunc
+
+func Test_motion_c_comment()
+  new
+  a
+/*
+ * Test pressing % on beginning/end
+ * of C comments.
+ */
+/* Another comment */
+.
+  norm gg0%
+  call assert_equal([4, 3], getpos('.')[1:2])
+  norm %
+  call assert_equal([1, 1], getpos('.')[1:2])
+  norm gg0l%
+  call assert_equal([4, 3], getpos('.')[1:2])
+  norm h%
+  call assert_equal([1, 1], getpos('.')[1:2])
+
+  norm G^
+  norm %
+  call assert_equal([5, 21], getpos('.')[1:2])
+  norm %
+  call assert_equal([5, 1], getpos('.')[1:2])
+
+  bw!
+endfunc
index 69e20cb1d6e4ff3ec5f23de7bca4575cab1bba84..8b06ac9f51a7f9456adaf1729a6193e9de36973e 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    24,
 /**/
     23,
 /**/