mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 20:08:17 +00:00
Merge #4140 'vim-patch:7.4.771'.
This commit is contained in:
@@ -287,7 +287,7 @@ local feed, insert, source = helpers.feed, helpers.insert, helpers.source
|
|||||||
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
|
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
|
||||||
|
|
||||||
describe('$test_name', function()
|
describe('$test_name', function()
|
||||||
setup(clear)
|
before_each(clear)
|
||||||
|
|
||||||
it('is working', function()
|
it('is working', function()
|
||||||
@{[join "\n", map { /^$/ ? '' : ' ' . $_ } @{$test_body_lines}]}
|
@{[join "\n", map { /^$/ ? '' : ' ' . $_ } @{$test_body_lines}]}
|
||||||
|
@@ -497,6 +497,7 @@ int searchit(
|
|||||||
pos_T start_pos;
|
pos_T start_pos;
|
||||||
int at_first_line;
|
int at_first_line;
|
||||||
int extra_col;
|
int extra_col;
|
||||||
|
int start_char_len;
|
||||||
int match_ok;
|
int match_ok;
|
||||||
long nmatched;
|
long nmatched;
|
||||||
int submatch = 0;
|
int submatch = 0;
|
||||||
@@ -519,16 +520,21 @@ int searchit(
|
|||||||
// When not accepting a match at the start position set "extra_col" to a
|
// 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
|
// non-zero value. Don't do that when starting at MAXCOL, since MAXCOL + 1
|
||||||
// is zero.
|
// is zero.
|
||||||
if ((options & SEARCH_START) || pos->col == MAXCOL) {
|
if (pos->col == MAXCOL) {
|
||||||
extra_col = 0;
|
start_char_len = 0;
|
||||||
} else if (dir != BACKWARD && has_mbyte
|
} else if (has_mbyte
|
||||||
&& pos->lnum >= 1 && pos->lnum <= buf->b_ml.ml_line_count
|
&& pos->lnum >= 1 && pos->lnum <= buf->b_ml.ml_line_count
|
||||||
&& pos->col < MAXCOL - 2) {
|
&& pos->col < MAXCOL - 2) {
|
||||||
// Watch out for the "col" being MAXCOL - 2, used in a closed fold.
|
// Watch out for the "col" being MAXCOL - 2, used in a closed fold.
|
||||||
ptr = ml_get_buf(buf, pos->lnum, FALSE) + pos->col;
|
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 {
|
} 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 */
|
start_pos = *pos; /* remember start pos for detecting no match */
|
||||||
@@ -679,16 +685,14 @@ int searchit(
|
|||||||
|| (lnum + regmatch.endpos[0].lnum
|
|| (lnum + regmatch.endpos[0].lnum
|
||||||
== start_pos.lnum
|
== start_pos.lnum
|
||||||
&& (int)regmatch.endpos[0].col - 1
|
&& (int)regmatch.endpos[0].col - 1
|
||||||
+ extra_col
|
< (int)start_pos.col + extra_col))
|
||||||
<= (int)start_pos.col))
|
|
||||||
: (lnum + regmatch.startpos[0].lnum
|
: (lnum + regmatch.startpos[0].lnum
|
||||||
< start_pos.lnum
|
< start_pos.lnum
|
||||||
|| (lnum + regmatch.startpos[0].lnum
|
|| (lnum + regmatch.startpos[0].lnum
|
||||||
== start_pos.lnum
|
== start_pos.lnum
|
||||||
&& (int)regmatch.startpos[0].col
|
&& (int)regmatch.startpos[0].col
|
||||||
+ extra_col
|
< (int)start_pos.col + extra_col)))) {
|
||||||
<= (int)start_pos.col)))) {
|
match_ok = true;
|
||||||
match_ok = TRUE;
|
|
||||||
matchpos = regmatch.startpos[0];
|
matchpos = regmatch.startpos[0];
|
||||||
endpos = regmatch.endpos[0];
|
endpos = regmatch.endpos[0];
|
||||||
submatch = first_submatch(®match);
|
submatch = first_submatch(®match);
|
||||||
|
@@ -517,7 +517,7 @@ static int included_patches[] = {
|
|||||||
774,
|
774,
|
||||||
773,
|
773,
|
||||||
// 772 NA
|
// 772 NA
|
||||||
// 771,
|
771,
|
||||||
// 770 NA
|
// 770 NA
|
||||||
769,
|
769,
|
||||||
768,
|
768,
|
||||||
|
26
test/functional/legacy/search_mbyte_spec.lua
Normal file
26
test/functional/legacy/search_mbyte_spec.lua
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
local helpers = require('test.functional.helpers')
|
||||||
|
local insert = helpers.insert
|
||||||
|
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
|
||||||
|
|
||||||
|
describe('search_mbyte', function()
|
||||||
|
before_each(clear)
|
||||||
|
|
||||||
|
it("search('multi-byte char', 'bce')", function()
|
||||||
|
insert([=[
|
||||||
|
Results:
|
||||||
|
|
||||||
|
Test bce:
|
||||||
|
A]=])
|
||||||
|
|
||||||
|
execute('/^Test bce:/+1')
|
||||||
|
execute([[$put =search('A', 'bce', line('.'))]])
|
||||||
|
|
||||||
|
-- Assert buffer contents.
|
||||||
|
expect([=[
|
||||||
|
Results:
|
||||||
|
|
||||||
|
Test bce:
|
||||||
|
A
|
||||||
|
4]=])
|
||||||
|
end)
|
||||||
|
end)
|
Reference in New Issue
Block a user