mirror of
https://github.com/neovim/neovim.git
synced 2025-01-01 17:23:36 -07:00
vim-patch:7.4.551
Problem: "ygn" may yank too much. (Fritzophrenic) Issue 295. Solution: Check the width of the next match. (Christian Brabandt) https://code.google.com/p/vim/source/detail?r=v7-4-551
This commit is contained in:
parent
91b378d349
commit
55f00f44d3
@ -3757,7 +3757,6 @@ current_quote (
|
|||||||
/*
|
/*
|
||||||
* Find next search match under cursor, cursor at end.
|
* Find next search match under cursor, cursor at end.
|
||||||
* Used while an operator is pending, and in Visual mode.
|
* Used while an operator is pending, and in Visual mode.
|
||||||
* TODO: redo only works when used in operator pending mode
|
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
current_search (
|
current_search (
|
||||||
@ -3792,7 +3791,7 @@ current_search (
|
|||||||
orig_pos = pos = curwin->w_cursor;
|
orig_pos = pos = curwin->w_cursor;
|
||||||
|
|
||||||
/* Is the pattern is zero-width? */
|
/* Is the pattern is zero-width? */
|
||||||
int one_char = is_one_char(spats[last_idx].pat);
|
int one_char = is_one_char(spats[last_idx].pat, true);
|
||||||
if (one_char == -1) {
|
if (one_char == -1) {
|
||||||
p_ws = old_p_ws;
|
p_ws = old_p_ws;
|
||||||
return FAIL; /* pattern not found */
|
return FAIL; /* pattern not found */
|
||||||
@ -3840,6 +3839,10 @@ current_search (
|
|||||||
int flags = forward ? SEARCH_END : 0;
|
int flags = forward ? SEARCH_END : 0;
|
||||||
pos_T start_pos = pos;
|
pos_T start_pos = pos;
|
||||||
|
|
||||||
|
/* Check again from the current cursor position,
|
||||||
|
* since the next match might actually be only one char wide */
|
||||||
|
one_char = is_one_char(spats[last_idx].pat, false);
|
||||||
|
|
||||||
/* 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 (!one_char)
|
if (!one_char)
|
||||||
@ -3878,24 +3881,33 @@ current_search (
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if the pattern is one character or zero-width.
|
* Check if the pattern is one character or zero-width.
|
||||||
|
* If move is true, check from the beginning of the buffer,
|
||||||
|
* else from the current cursor position.
|
||||||
* Returns TRUE, FALSE or -1 for failure.
|
* Returns TRUE, FALSE or -1 for failure.
|
||||||
*/
|
*/
|
||||||
static int is_one_char(char_u *pattern)
|
static int is_one_char(char_u *pattern, bool move)
|
||||||
{
|
{
|
||||||
regmmatch_T regmatch;
|
regmmatch_T regmatch;
|
||||||
int nmatched = 0;
|
int nmatched = 0;
|
||||||
int result = -1;
|
int result = -1;
|
||||||
pos_T pos;
|
pos_T pos;
|
||||||
int save_called_emsg = called_emsg;
|
int save_called_emsg = called_emsg;
|
||||||
|
int flag = 0;
|
||||||
|
|
||||||
if (search_regcomp(pattern, RE_SEARCH, RE_SEARCH,
|
if (search_regcomp(pattern, RE_SEARCH, RE_SEARCH,
|
||||||
SEARCH_KEEP, ®match) == FAIL)
|
SEARCH_KEEP, ®match) == FAIL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* move to match */
|
/* move to match */
|
||||||
|
if (move) {
|
||||||
clearpos(&pos);
|
clearpos(&pos);
|
||||||
|
} else {
|
||||||
|
pos = curwin->w_cursor;
|
||||||
|
/* accept a match at the cursor position */
|
||||||
|
flag = SEARCH_START;
|
||||||
|
}
|
||||||
if (searchit(curwin, curbuf, &pos, FORWARD, spats[last_idx].pat, 1,
|
if (searchit(curwin, curbuf, &pos, FORWARD, spats[last_idx].pat, 1,
|
||||||
SEARCH_KEEP, RE_SEARCH, 0, NULL) != FAIL) {
|
SEARCH_KEEP + flag, RE_SEARCH, 0, NULL) != FAIL) {
|
||||||
/* Zero-width pattern should match somewhere, then we can check if
|
/* Zero-width pattern should match somewhere, then we can check if
|
||||||
* start and end are in the same position. */
|
* start and end are in the same position. */
|
||||||
called_emsg = FALSE;
|
called_emsg = FALSE;
|
||||||
|
@ -79,6 +79,8 @@ ggdgn.
|
|||||||
:" test repeating gUgn
|
:" test repeating gUgn
|
||||||
/^Depp
|
/^Depp
|
||||||
gggUgn.
|
gggUgn.
|
||||||
|
gg/a:0\@!\zs\d\+
|
||||||
|
nygnop
|
||||||
:/^start:/,/^end:/wq! test.out
|
:/^start:/,/^end:/wq! test.out
|
||||||
ENDTEST
|
ENDTEST
|
||||||
|
|
||||||
@ -108,6 +110,11 @@ 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++)
|
for (i=0; i<=10; i++)
|
||||||
|
a:10
|
||||||
|
|
||||||
|
a:1
|
||||||
|
|
||||||
|
a:20
|
||||||
Y
|
Y
|
||||||
text
|
text
|
||||||
Y
|
Y
|
||||||
|
@ -49,6 +49,12 @@ 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++)
|
for (j=0; i<=10; i++)
|
||||||
|
a:10
|
||||||
|
|
||||||
|
a:1
|
||||||
|
1
|
||||||
|
|
||||||
|
a:20
|
||||||
|
|
||||||
text
|
text
|
||||||
Y
|
Y
|
||||||
|
@ -187,7 +187,7 @@ static int included_patches[] = {
|
|||||||
//554,
|
//554,
|
||||||
//553,
|
//553,
|
||||||
552,
|
552,
|
||||||
//551,
|
551,
|
||||||
//550,
|
//550,
|
||||||
549,
|
549,
|
||||||
//548 NA
|
//548 NA
|
||||||
|
Loading…
Reference in New Issue
Block a user