Skip to content

Commit 21f990e

Browse files
committed
patch 8.1.0274: 'incsearch' triggers on ":source"
Problem: 'incsearch' triggers on ":source". Solution: Check for the whole command name.
1 parent ef73a28 commit 21f990e

3 files changed

Lines changed: 33 additions & 22 deletions

File tree

src/ex_getln.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,10 @@ do_incsearch_highlighting(int firstc, incsearch_state_T *is_state,
293293
// Skip over "substitute" to find the pattern separator.
294294
for (p = cmd; ASCII_ISALPHA(*p); ++p)
295295
;
296-
if (*p != NUL)
296+
if (*p != NUL
297+
&& (STRNCMP(cmd, "substitute", p - cmd) == 0
298+
|| STRNCMP(cmd, "global", p - cmd) == 0
299+
|| STRNCMP(cmd, "vglobal", p - cmd) == 0))
297300
{
298301
delim = *p++;
299302
end = skip_regexp(p, delim, p_magic, NULL);

src/testdir/test_search.vim

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -342,26 +342,6 @@ func Test_searchc()
342342
bw!
343343
endfunc
344344

345-
func Test_search_cmdline3()
346-
if !exists('+incsearch')
347-
return
348-
endif
349-
" need to disable char_avail,
350-
" so that expansion of commandline works
351-
call test_override("char_avail", 1)
352-
new
353-
call setline(1, [' 1', ' 2 the~e', ' 3 the theother'])
354-
set incsearch
355-
1
356-
" first match
357-
call feedkeys("/the\<c-l>\<cr>", 'tx')
358-
call assert_equal(' 2 the~e', getline('.'))
359-
" clean up
360-
set noincsearch
361-
call test_override("char_avail", 0)
362-
bw!
363-
endfunc
364-
365345
func Cmdline3_prep()
366346
" need to disable char_avail,
367347
" so that expansion of commandline works
@@ -377,6 +357,19 @@ func Cmdline3_cleanup()
377357
bw!
378358
endfunc
379359

360+
func Test_search_cmdline3()
361+
if !exists('+incsearch')
362+
return
363+
endif
364+
call Cmdline3_prep()
365+
1
366+
" first match
367+
call feedkeys("/the\<c-l>\<cr>", 'tx')
368+
call assert_equal(' 2 the~e', getline('.'))
369+
370+
call Cmdline3_cleanup()
371+
endfunc
372+
380373
func Test_search_cmdline3s()
381374
if !exists('+incsearch')
382375
return
@@ -385,6 +378,12 @@ func Test_search_cmdline3s()
385378
1
386379
call feedkeys(":%s/the\<c-l>/xxx\<cr>", 'tx')
387380
call assert_equal(' 2 xxxe', getline('.'))
381+
undo
382+
call feedkeys(":%subs/the\<c-l>/xxx\<cr>", 'tx')
383+
call assert_equal(' 2 xxxe', getline('.'))
384+
undo
385+
call feedkeys(":%substitute/the\<c-l>/xxx\<cr>", 'tx')
386+
call assert_equal(' 2 xxxe', getline('.'))
388387

389388
call Cmdline3_cleanup()
390389
endfunc
@@ -397,6 +396,9 @@ func Test_search_cmdline3g()
397396
1
398397
call feedkeys(":g/the\<c-l>/d\<cr>", 'tx')
399398
call assert_equal(' 3 the theother', getline(2))
399+
undo
400+
call feedkeys(":global/the\<c-l>/d\<cr>", 'tx')
401+
call assert_equal(' 3 the theother', getline(2))
400402

401403
call Cmdline3_cleanup()
402404
endfunc
@@ -410,6 +412,10 @@ func Test_search_cmdline3v()
410412
call feedkeys(":v/the\<c-l>/d\<cr>", 'tx')
411413
call assert_equal(1, line('$'))
412414
call assert_equal(' 2 the~e', getline(1))
415+
undo
416+
call feedkeys(":vglobal/the\<c-l>/d\<cr>", 'tx')
417+
call assert_equal(1, line('$'))
418+
call assert_equal(' 2 the~e', getline(1))
413419

414420
call Cmdline3_cleanup()
415421
endfunc
@@ -518,7 +524,7 @@ func Test_search_cmdline7()
518524
" so that expansion of commandline works
519525
call test_override("char_avail", 1)
520526
new
521-
let @/='b'
527+
let @/ = 'b'
522528
call setline(1, [' bbvimb', ''])
523529
set incsearch
524530
" first match

src/version.c

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

795795
static int included_patches[] =
796796
{ /* Add new patch number below this line */
797+
/**/
798+
274,
797799
/**/
798800
273,
799801
/**/

0 commit comments

Comments
 (0)