mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:7.4.771
Problem: Search does not handle multi-byte character at the start position
correctly.
Solution: Take byte size of character into account. (Yukihiro Nakadaira)
5f1e68b7bc
This commit is contained in:
parent
8f22031708
commit
7d2d4b1918
@ -497,6 +497,7 @@ int searchit(
|
||||
pos_T start_pos;
|
||||
int at_first_line;
|
||||
int extra_col;
|
||||
int start_char_len;
|
||||
int match_ok;
|
||||
long nmatched;
|
||||
int submatch = 0;
|
||||
@ -519,16 +520,21 @@ int searchit(
|
||||
// When not accepting a match at the start position set "extra_col" to a
|
||||
// non-zero value. Don't do that when starting at MAXCOL, since MAXCOL + 1
|
||||
// is zero.
|
||||
if ((options & SEARCH_START) || pos->col == MAXCOL) {
|
||||
extra_col = 0;
|
||||
} else if (dir != BACKWARD && has_mbyte
|
||||
if (pos->col == MAXCOL) {
|
||||
start_char_len = 0;
|
||||
} else if (has_mbyte
|
||||
&& pos->lnum >= 1 && pos->lnum <= buf->b_ml.ml_line_count
|
||||
&& pos->col < MAXCOL - 2) {
|
||||
// Watch out for the "col" being MAXCOL - 2, used in a closed fold.
|
||||
ptr = ml_get_buf(buf, pos->lnum, FALSE) + pos->col;
|
||||
extra_col = *ptr == NUL ? 1 : (*mb_ptr2len)(ptr);
|
||||
start_char_len = *ptr == NUL ? 1 : (*mb_ptr2len)(ptr);
|
||||
} else {
|
||||
extra_col = 1;
|
||||
start_char_len = 1;
|
||||
}
|
||||
if (dir == FORWARD) {
|
||||
extra_col = (options & SEARCH_START) ? 0 : start_char_len;
|
||||
} else {
|
||||
extra_col = (options & SEARCH_START) ? start_char_len : 0;
|
||||
}
|
||||
|
||||
start_pos = *pos; /* remember start pos for detecting no match */
|
||||
@ -679,15 +685,13 @@ int searchit(
|
||||
|| (lnum + regmatch.endpos[0].lnum
|
||||
== start_pos.lnum
|
||||
&& (int)regmatch.endpos[0].col - 1
|
||||
+ extra_col
|
||||
<= (int)start_pos.col))
|
||||
< (int)start_pos.col + extra_col))
|
||||
: (lnum + regmatch.startpos[0].lnum
|
||||
< start_pos.lnum
|
||||
|| (lnum + regmatch.startpos[0].lnum
|
||||
== start_pos.lnum
|
||||
&& (int)regmatch.startpos[0].col
|
||||
+ extra_col
|
||||
<= (int)start_pos.col)))) {
|
||||
< (int)start_pos.col + extra_col)))) {
|
||||
match_ok = TRUE;
|
||||
matchpos = regmatch.startpos[0];
|
||||
endpos = regmatch.endpos[0];
|
||||
|
@ -363,7 +363,7 @@ static int included_patches[] = {
|
||||
774,
|
||||
773,
|
||||
// 772 NA
|
||||
// 771,
|
||||
771,
|
||||
// 770 NA
|
||||
// 769,
|
||||
// 768,
|
||||
|
Loading…
Reference in New Issue
Block a user