Skip to content

Commit 6b69e5c

Browse files
committed
patch 8.1.0024: % command not testded on #ifdef and comment
Problem: % command not testded on #ifdef and comment. Solution: Add tests. (Dominique Pelle, closes #2956)
1 parent 22c1056 commit 6b69e5c

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

src/testdir/test_goto.vim

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,3 +309,65 @@ func Test_gd_local_block()
309309
\ ]
310310
call XTest_goto_decl('1gd', lines, 11, 11)
311311
endfunc
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

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
24,
764766
/**/
765767
23,
766768
/**/

0 commit comments

Comments
 (0)