1
0
forked from aniani/vim

patch 9.0.0950: the pattern "\_s\zs" matches at EOL

Problem:    The pattern "\_s\zs" matches at EOL.
Solution:   Make the pattern "\_s\zs" match at the start of the next line.
            (closes #11617)
This commit is contained in:
Bram Moolenaar
2022-11-25 21:13:47 +00:00
parent ef2c325f5e
commit c96311b5be
5 changed files with 39 additions and 10 deletions

View File

@@ -1093,7 +1093,6 @@ static void cleanup_subexpr(void);
#ifdef FEAT_SYN_HL #ifdef FEAT_SYN_HL
static void cleanup_zsubexpr(void); static void cleanup_zsubexpr(void);
#endif #endif
static void reg_nextline(void);
static int match_with_backref(linenr_T start_lnum, colnr_T start_col, linenr_T end_lnum, colnr_T end_col, int *bytelen); static int match_with_backref(linenr_T start_lnum, colnr_T start_col, linenr_T end_lnum, colnr_T end_col, int *bytelen);
/* /*

View File

@@ -1742,7 +1742,8 @@ nfa_regatom(void)
break; break;
} }
} }
semsg(_(e_nfa_regexp_unknown_operator_percent_chr), no_Magic(c)); semsg(_(e_nfa_regexp_unknown_operator_percent_chr),
no_Magic(c));
return FAIL; return FAIL;
} }
break; break;
@@ -4013,7 +4014,8 @@ log_subexpr(regsub_T *sub)
for (j = 0; j < sub->in_use; j++) for (j = 0; j < sub->in_use; j++)
if (REG_MULTI) if (REG_MULTI)
fprintf(log_fd, "*** group %d, start: c=%d, l=%d, end: c=%d, l=%d\n", fprintf(log_fd,
"*** group %d, start: c=%d, l=%d, end: c=%d, l=%d\n",
j, j,
sub->list.multi[j].start_col, sub->list.multi[j].start_col,
(int)sub->list.multi[j].start_lnum, (int)sub->list.multi[j].start_lnum,

View File

@@ -793,6 +793,8 @@ searchit(
if (dir == FORWARD && at_first_line) if (dir == FORWARD && at_first_line)
{ {
match_ok = TRUE; match_ok = TRUE;
matchcol = col;
/* /*
* When the match starts in a next line it's certainly * When the match starts in a next line it's certainly
* past the start position. * past the start position.
@@ -837,7 +839,9 @@ searchit(
} }
else else
{ {
matchcol = matchpos.col; // Advance "matchcol" to the next character.
// This does not use matchpos.col, because
// "\zs" may have have set it.
if (ptr[matchcol] != NUL) if (ptr[matchcol] != NUL)
{ {
if (has_mbyte) if (has_mbyte)

View File

@@ -1884,7 +1884,7 @@ func Test_search_smartcase_utf8()
set ignorecase& smartcase& set ignorecase& smartcase&
let &encoding = save_enc let &encoding = save_enc
close! bwipe!
endfunc endfunc
" Test searching past the end of a file " Test searching past the end of a file
@@ -1893,7 +1893,29 @@ func Test_search_past_eof()
call setline(1, ['Line']) call setline(1, ['Line'])
exe "normal /\\n\\zs\<CR>" exe "normal /\\n\\zs\<CR>"
call assert_equal([1, 4], [line('.'), col('.')]) call assert_equal([1, 4], [line('.'), col('.')])
close! bwipe!
endfunc
" Test setting the start of the match and still finding a next match in the
" same line.
func Test_search_set_start_same_line()
new
set cpo-=c
call setline(1, ['1', '2', '3 .', '4', '5'])
exe "normal /\\_s\\zs\\S\<CR>"
call assert_equal([2, 1], [line('.'), col('.')])
exe 'normal n'
call assert_equal([3, 1], [line('.'), col('.')])
exe 'normal n'
call assert_equal([3, 3], [line('.'), col('.')])
exe 'normal n'
call assert_equal([4, 1], [line('.'), col('.')])
exe 'normal n'
call assert_equal([5, 1], [line('.'), col('.')])
set cpo+=c
bwipe!
endfunc endfunc
" Test for various search offsets " Test for various search offsets

View File

@@ -695,6 +695,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
950,
/**/ /**/
949, 949,
/**/ /**/