mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
updated for version 7.3.1275
Problem: "gn" does not work when the match is a single character. Solution: Fix it, add a test. (Christian Brabandt)
This commit is contained in:
21
src/search.c
21
src/search.c
@@ -4489,7 +4489,7 @@ current_quote(oap, count, include, quotechar)
|
|||||||
#endif /* FEAT_TEXTOBJ */
|
#endif /* FEAT_TEXTOBJ */
|
||||||
|
|
||||||
#if defined(FEAT_VISUAL) || defined(PROTO)
|
#if defined(FEAT_VISUAL) || defined(PROTO)
|
||||||
static int is_zerowidth __ARGS((char_u *pattern));
|
static int is_one_char __ARGS((char_u *pattern));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find next search match under cursor, cursor at end.
|
* Find next search match under cursor, cursor at end.
|
||||||
@@ -4510,7 +4510,7 @@ current_search(count, forward)
|
|||||||
char_u old_p_ws = p_ws;
|
char_u old_p_ws = p_ws;
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
pos_T save_VIsual;
|
pos_T save_VIsual;
|
||||||
int zerowidth = FALSE;
|
int one_char;
|
||||||
|
|
||||||
/* wrapping should not occur */
|
/* wrapping should not occur */
|
||||||
p_ws = FALSE;
|
p_ws = FALSE;
|
||||||
@@ -4540,9 +4540,9 @@ current_search(count, forward)
|
|||||||
orig_pos = pos = start_pos = curwin->w_cursor;
|
orig_pos = pos = start_pos = curwin->w_cursor;
|
||||||
|
|
||||||
/* Is the pattern is zero-width? */
|
/* Is the pattern is zero-width? */
|
||||||
zerowidth = is_zerowidth(spats[last_idx].pat);
|
one_char = is_one_char(spats[last_idx].pat);
|
||||||
if (zerowidth == -1)
|
if (one_char == -1)
|
||||||
return FAIL;
|
return FAIL; /* invalid pattern */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The trick is to first search backwards and then search forward again,
|
* The trick is to first search backwards and then search forward again,
|
||||||
@@ -4557,7 +4557,7 @@ current_search(count, forward)
|
|||||||
dir = !i;
|
dir = !i;
|
||||||
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
if (!dir && !zerowidth)
|
if (!dir && !one_char)
|
||||||
flags = SEARCH_END;
|
flags = SEARCH_END;
|
||||||
|
|
||||||
result = searchit(curwin, curbuf, &pos, (dir ? FORWARD : BACKWARD),
|
result = searchit(curwin, curbuf, &pos, (dir ? FORWARD : BACKWARD),
|
||||||
@@ -4598,7 +4598,7 @@ current_search(count, forward)
|
|||||||
|
|
||||||
/* move to match, except for zero-width matches, in which case, we are
|
/* move to match, except for zero-width matches, in which case, we are
|
||||||
* already on the next match */
|
* already on the next match */
|
||||||
if (!zerowidth)
|
if (!one_char)
|
||||||
result = searchit(curwin, curbuf, &pos, (forward ? FORWARD : BACKWARD),
|
result = searchit(curwin, curbuf, &pos, (forward ? FORWARD : BACKWARD),
|
||||||
spats[last_idx].pat, 0L, flags | SEARCH_KEEP, RE_SEARCH, 0, NULL);
|
spats[last_idx].pat, 0L, flags | SEARCH_KEEP, RE_SEARCH, 0, NULL);
|
||||||
|
|
||||||
@@ -4645,11 +4645,11 @@ current_search(count, forward)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if the pattern is zero-width.
|
* Check if the pattern is one character or zero-width.
|
||||||
* Returns TRUE, FALSE or -1 for failure.
|
* Returns TRUE, FALSE or -1 for failure.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
is_zerowidth(pattern)
|
is_one_char(pattern)
|
||||||
char_u *pattern;
|
char_u *pattern;
|
||||||
{
|
{
|
||||||
regmmatch_T regmatch;
|
regmmatch_T regmatch;
|
||||||
@@ -4677,6 +4677,9 @@ is_zerowidth(pattern)
|
|||||||
result = (nmatched != 0
|
result = (nmatched != 0
|
||||||
&& regmatch.startpos[0].lnum == regmatch.endpos[0].lnum
|
&& regmatch.startpos[0].lnum == regmatch.endpos[0].lnum
|
||||||
&& regmatch.startpos[0].col == regmatch.endpos[0].col);
|
&& regmatch.startpos[0].col == regmatch.endpos[0].col);
|
||||||
|
|
||||||
|
if (!result && incl(&pos) == 0 && pos.col == regmatch.endpos[0].col)
|
||||||
|
result = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
called_emsg |= save_called_emsg;
|
called_emsg |= save_called_emsg;
|
||||||
|
@@ -44,7 +44,8 @@ gnd/[u]niquepattern/s
|
|||||||
vlgnd
|
vlgnd
|
||||||
/mother
|
/mother
|
||||||
:set selection=exclusive
|
:set selection=exclusive
|
||||||
$cgNmongoose
|
$cgNmongoose/i
|
||||||
|
cgnj
|
||||||
:/^start:/,/^end:/wq! test.out
|
:/^start:/,/^end:/wq! test.out
|
||||||
ENDTEST
|
ENDTEST
|
||||||
|
|
||||||
@@ -73,4 +74,5 @@ zero width pattern
|
|||||||
delete first and last chars
|
delete first and last chars
|
||||||
uniquepattern uniquepattern
|
uniquepattern uniquepattern
|
||||||
my very excellent mother just served us nachos
|
my very excellent mother just served us nachos
|
||||||
|
for (i=0; i<=10; i++)
|
||||||
end:
|
end:
|
||||||
|
@@ -26,4 +26,5 @@ zerowidth pattern
|
|||||||
elete first and last char
|
elete first and last char
|
||||||
uniquepattern
|
uniquepattern
|
||||||
my very excellent mongoose just served us nachos
|
my very excellent mongoose just served us nachos
|
||||||
|
for (j=0; i<=10; i++)
|
||||||
end:
|
end:
|
||||||
|
@@ -728,6 +728,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 */
|
||||||
|
/**/
|
||||||
|
1275,
|
||||||
/**/
|
/**/
|
||||||
1274,
|
1274,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user