mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.2885: searching for \%'> does not match linewise end of line
Problem: searching for \%'> does not match linewise end of line. (Tim Chase)
Solution: Match end of line if column is MAXCOL. (closes vim/vim#8238)
872bee557e
This commit is contained in:
parent
31ea80649d
commit
7e0d50b16e
@ -3974,19 +3974,27 @@ static bool regmatch(
|
|||||||
|
|
||||||
pos = getmark_buf(rex.reg_buf, mark, false);
|
pos = getmark_buf(rex.reg_buf, mark, false);
|
||||||
if (pos == NULL // mark doesn't exist
|
if (pos == NULL // mark doesn't exist
|
||||||
|| pos->lnum <= 0 // mark isn't set in reg_buf
|
|| pos->lnum <= 0) { // mark isn't set in reg_buf
|
||||||
|| (pos->lnum == rex.lnum + rex.reg_firstlnum
|
status = RA_NOMATCH;
|
||||||
? (pos->col == (colnr_T)(rex.input - rex.line)
|
} else {
|
||||||
|
const colnr_T pos_col = pos->lnum == rex.lnum + rex.reg_firstlnum
|
||||||
|
&& pos->col == MAXCOL
|
||||||
|
? (colnr_T)STRLEN(reg_getline(pos->lnum - rex.reg_firstlnum))
|
||||||
|
: pos->col;
|
||||||
|
|
||||||
|
if (pos->lnum == rex.lnum + rex.reg_firstlnum
|
||||||
|
? (pos_col == (colnr_T)(rex.input - rex.line)
|
||||||
? (cmp == '<' || cmp == '>')
|
? (cmp == '<' || cmp == '>')
|
||||||
: (pos->col < (colnr_T)(rex.input - rex.line)
|
: (pos_col < (colnr_T)(rex.input - rex.line)
|
||||||
? cmp != '>'
|
? cmp != '>'
|
||||||
: cmp != '<'))
|
: cmp != '<'))
|
||||||
: (pos->lnum < rex.lnum + rex.reg_firstlnum
|
: (pos->lnum < rex.lnum + rex.reg_firstlnum
|
||||||
? cmp != '>'
|
? cmp != '>'
|
||||||
: cmp != '<'))) {
|
: cmp != '<')) {
|
||||||
status = RA_NOMATCH;
|
status = RA_NOMATCH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RE_VISUAL:
|
case RE_VISUAL:
|
||||||
|
@ -6055,22 +6055,28 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start,
|
|||||||
{
|
{
|
||||||
pos_T *pos = getmark_buf(rex.reg_buf, t->state->val, false);
|
pos_T *pos = getmark_buf(rex.reg_buf, t->state->val, false);
|
||||||
|
|
||||||
// Compare the mark position to the match position.
|
// Compare the mark position to the match position, if the mark
|
||||||
result = (pos != NULL // mark doesn't exist
|
// exists and mark is set in reg_buf.
|
||||||
&& pos->lnum > 0 // mark isn't set in reg_buf
|
if (pos != NULL && pos->lnum > 0) {
|
||||||
&& (pos->lnum == rex.lnum + rex.reg_firstlnum
|
const colnr_T pos_col = pos->lnum == rex.lnum + rex.reg_firstlnum
|
||||||
? (pos->col == (colnr_T)(rex.input - rex.line)
|
&& pos->col == MAXCOL
|
||||||
|
? (colnr_T)STRLEN(reg_getline(pos->lnum - rex.reg_firstlnum))
|
||||||
|
: pos->col;
|
||||||
|
|
||||||
|
result = pos->lnum == rex.lnum + rex.reg_firstlnum
|
||||||
|
? (pos_col == (colnr_T)(rex.input - rex.line)
|
||||||
? t->state->c == NFA_MARK
|
? t->state->c == NFA_MARK
|
||||||
: (pos->col < (colnr_T)(rex.input - rex.line)
|
: (pos_col < (colnr_T)(rex.input - rex.line)
|
||||||
? t->state->c == NFA_MARK_GT
|
? t->state->c == NFA_MARK_GT
|
||||||
: t->state->c == NFA_MARK_LT))
|
: t->state->c == NFA_MARK_LT))
|
||||||
: (pos->lnum < rex.lnum + rex.reg_firstlnum
|
: (pos->lnum < rex.lnum + rex.reg_firstlnum
|
||||||
? t->state->c == NFA_MARK_GT
|
? t->state->c == NFA_MARK_GT
|
||||||
: t->state->c == NFA_MARK_LT)));
|
: t->state->c == NFA_MARK_LT);
|
||||||
if (result) {
|
if (result) {
|
||||||
add_here = true;
|
add_here = true;
|
||||||
add_state = t->state->out;
|
add_state = t->state->out;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1177,13 +1177,28 @@ func Test_look_behind()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_search_visual_area_linewise()
|
||||||
|
new
|
||||||
|
call setline(1, ['aa', 'bb', 'cc'])
|
||||||
|
exe "normal 2GV\<Esc>"
|
||||||
|
for engine in [1, 2]
|
||||||
|
exe 'set regexpengine=' .. engine
|
||||||
|
exe "normal gg/\\%'<\<CR>>"
|
||||||
|
call assert_equal([0, 2, 1, 0, 1], getcurpos(), 'engine ' .. engine)
|
||||||
|
exe "normal gg/\\%'>\<CR>"
|
||||||
|
call assert_equal([0, 2, 2, 0, 2], getcurpos(), 'engine ' .. engine)
|
||||||
|
endfor
|
||||||
|
|
||||||
|
bwipe!
|
||||||
|
set regexpengine&
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_search_sentence()
|
func Test_search_sentence()
|
||||||
new
|
new
|
||||||
" this used to cause a crash
|
" this used to cause a crash
|
||||||
call assert_fails("/\\%')", 'E486')
|
|
||||||
call assert_fails("/", 'E486')
|
|
||||||
/\%'(
|
/\%'(
|
||||||
/
|
/
|
||||||
|
bwipe
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test that there is no crash when there is a last search pattern but no last
|
" Test that there is no crash when there is a last search pattern but no last
|
||||||
|
Loading…
Reference in New Issue
Block a user