@@ -309,3 +309,65 @@ func Test_gd_local_block()
309309 \ ]
310310 call XTest_goto_decl (' 1gd' , lines , 11 , 11 )
311311endfunc
312+
313+ func Test_motion_if_elif_else_endif ()
314+ new
315+ a
316+ /* Test pressing % on #if , #else #elsif and #endif ,
317+ * with nested #if
318+ * /
319+ #if FOO
320+ /* ... */
321+ # if BAR
322+ /* ... */
323+ # endif
324+ #elif BAR
325+ /* ... */
326+ #else
327+ /* ... */
328+ #endif
329+ .
330+ /#if FOO
331+ norm %
332+ call assert_equal ([9 , 1 ], getpos (' .' )[1 :2 ])
333+ norm %
334+ call assert_equal ([11 , 1 ], getpos (' .' )[1 :2 ])
335+ norm %
336+ call assert_equal ([13 , 1 ], getpos (' .' )[1 :2 ])
337+ norm %
338+ call assert_equal ([4 , 1 ], getpos (' .' )[1 :2 ])
339+ /# if BAR
340+ norm $ %
341+ call assert_equal ([8 , 1 ], getpos (' .' )[1 :2 ])
342+ norm $ %
343+ call assert_equal ([6 , 1 ], getpos (' .' )[1 :2 ])
344+
345+ bw !
346+ endfunc
347+
348+ func Test_motion_c_comment ()
349+ new
350+ a
351+ /*
352+ * Test pressing % on beginning/end
353+ * of C comments .
354+ * /
355+ /* Another comment */
356+ .
357+ norm gg0%
358+ call assert_equal ([4 , 3 ], getpos (' .' )[1 :2 ])
359+ norm %
360+ call assert_equal ([1 , 1 ], getpos (' .' )[1 :2 ])
361+ norm gg0l%
362+ call assert_equal ([4 , 3 ], getpos (' .' )[1 :2 ])
363+ norm h %
364+ call assert_equal ([1 , 1 ], getpos (' .' )[1 :2 ])
365+
366+ norm G^
367+ norm %
368+ call assert_equal ([5 , 21 ], getpos (' .' )[1 :2 ])
369+ norm %
370+ call assert_equal ([5 , 1 ], getpos (' .' )[1 :2 ])
371+
372+ bw !
373+ endfunc
0 commit comments