mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:7.4.582 #2653
Problem: Can't match "%>80v" properly. (Axel Bender)
Solution: Correctly handle ">". (Christian Brabandt)
https://github.com/vim/vim/commit/v7-4-582
See https://groups.google.com/d/msg/vim_dev/n-02i4FnOcw/P3Yyx1OLeXgJ
Slightly adapted due to the long_u refactoring in
2ceb1c74d5
.
Reviewed-by: Florian Walch <florian@fwalch.com>
Fixes #2726
This commit is contained in:
parent
c6da503336
commit
5a9ad68b25
@ -5742,17 +5742,27 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm
|
|||||||
|
|
||||||
// Bail out quickly when there can't be a match, avoid the overhead of
|
// Bail out quickly when there can't be a match, avoid the overhead of
|
||||||
// win_linetabsize() on long lines.
|
// win_linetabsize() on long lines.
|
||||||
if ((col > t->state->val && op != 1)
|
if (op != 1 && col > t->state->val) {
|
||||||
|| (col - 1 > t->state->val && op == 1)) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
uintmax_t lts = win_linetabsize(reg_win == NULL ? curwin : reg_win,
|
|
||||||
regline,
|
result = FALSE;
|
||||||
col);
|
win_T *wp = reg_win == NULL ? curwin : reg_win;
|
||||||
assert(t->state->val >= 0);
|
if (op == 1 && col - 1 > t->state->val && col > 100) {
|
||||||
result = nfa_re_num_cmp((uintmax_t)t->state->val,
|
long ts = wp->w_buffer->b_p_ts;
|
||||||
op,
|
|
||||||
lts + 1);
|
// Guess that a character won't use more columns than 'tabstop',
|
||||||
|
// with a minimum of 4.
|
||||||
|
if (ts < 4) {
|
||||||
|
ts = 4;
|
||||||
|
}
|
||||||
|
result = col > t->state->val * ts;
|
||||||
|
}
|
||||||
|
if (!result) {
|
||||||
|
uintmax_t lts = win_linetabsize(wp, regline, col);
|
||||||
|
assert(t->state->val >= 0);
|
||||||
|
result = nfa_re_num_cmp((uintmax_t)t->state->val, op, lts + 1);
|
||||||
|
}
|
||||||
if (result) {
|
if (result) {
|
||||||
add_here = true;
|
add_here = true;
|
||||||
add_state = t->state->out;
|
add_state = t->state->out;
|
||||||
|
@ -7,6 +7,7 @@ actually tried.
|
|||||||
STARTTEST
|
STARTTEST
|
||||||
:so small.vim
|
:so small.vim
|
||||||
:" tl is a List of Lists with:
|
:" tl is a List of Lists with:
|
||||||
|
:" regexp engine
|
||||||
:" regexp pattern
|
:" regexp pattern
|
||||||
:" text to test the pattern on
|
:" text to test the pattern on
|
||||||
:" expected match (optional)
|
:" expected match (optional)
|
||||||
@ -451,6 +452,9 @@ STARTTEST
|
|||||||
:"""" Skip adding state twice
|
:"""" Skip adding state twice
|
||||||
:call add(tl, [2, '^\%(\%(^\s*#\s*if\>\|#\s*if\)\)\(\%>1c.*$\)\@=', "#if FOO", "#if", ' FOO'])
|
:call add(tl, [2, '^\%(\%(^\s*#\s*if\>\|#\s*if\)\)\(\%>1c.*$\)\@=', "#if FOO", "#if", ' FOO'])
|
||||||
:"
|
:"
|
||||||
|
:""" Test \%V atom
|
||||||
|
:call add(tl, [2, '\%>70vGesamt', 'Jean-Michel Charlier & Victor Hubinon\Gesamtausgabe [Salleck] Buck Danny {Jean-Michel Charlier & Victor Hubinon}\Gesamtausgabe', 'Gesamt'])
|
||||||
|
:"
|
||||||
:"""" Run the tests
|
:"""" Run the tests
|
||||||
:"
|
:"
|
||||||
:for t in tl
|
:for t in tl
|
||||||
|
@ -1030,6 +1030,9 @@ OK 2 - [0-9a-zA-Z]\{8}-\([0-9a-zA-Z]\{4}-\)\{3}[0-9a-zA-Z]\{12}
|
|||||||
OK 0 - ^\%(\%(^\s*#\s*if\>\|#\s*if\)\)\(\%>1c.*$\)\@=
|
OK 0 - ^\%(\%(^\s*#\s*if\>\|#\s*if\)\)\(\%>1c.*$\)\@=
|
||||||
OK 1 - ^\%(\%(^\s*#\s*if\>\|#\s*if\)\)\(\%>1c.*$\)\@=
|
OK 1 - ^\%(\%(^\s*#\s*if\>\|#\s*if\)\)\(\%>1c.*$\)\@=
|
||||||
OK 2 - ^\%(\%(^\s*#\s*if\>\|#\s*if\)\)\(\%>1c.*$\)\@=
|
OK 2 - ^\%(\%(^\s*#\s*if\>\|#\s*if\)\)\(\%>1c.*$\)\@=
|
||||||
|
OK 0 - \%>70vGesamt
|
||||||
|
OK 1 - \%>70vGesamt
|
||||||
|
OK 2 - \%>70vGesamt
|
||||||
multi-line tests
|
multi-line tests
|
||||||
OK 0 - ^.\(.\).\_..\1.
|
OK 0 - ^.\(.\).\_..\1.
|
||||||
OK 1 - ^.\(.\).\_..\1.
|
OK 1 - ^.\(.\).\_..\1.
|
||||||
|
@ -218,7 +218,7 @@ static int included_patches[] = {
|
|||||||
585,
|
585,
|
||||||
//584 NA
|
//584 NA
|
||||||
//583 NA
|
//583 NA
|
||||||
//582,
|
582,
|
||||||
//581 NA
|
//581 NA
|
||||||
580,
|
580,
|
||||||
579,
|
579,
|
||||||
|
Loading…
Reference in New Issue
Block a user