mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.1.2236: ml_get error if pattern matches beyond last line
Problem: Ml_get error if pattern matches beyond last line. Solution: Adjust position if needed. (Christian Brabandt, closes #5139)
This commit is contained in:
@@ -3947,6 +3947,11 @@ do_sub(exarg_T *eap)
|
|||||||
VIM_CLEAR(sub_firstline);
|
VIM_CLEAR(sub_firstline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Match might be after the last line for "\n\zs" matching at
|
||||||
|
// the end of the last line.
|
||||||
|
if (lnum > curbuf->b_ml.ml_line_count)
|
||||||
|
break;
|
||||||
|
|
||||||
if (sub_firstline == NULL)
|
if (sub_firstline == NULL)
|
||||||
{
|
{
|
||||||
sub_firstline = vim_strsave(ml_get(sub_firstlnum));
|
sub_firstline = vim_strsave(ml_get(sub_firstlnum));
|
||||||
|
@@ -413,6 +413,7 @@ func Run_SubCmd_Tests(tests)
|
|||||||
for t in a:tests
|
for t in a:tests
|
||||||
let start = line('.') + 1
|
let start = line('.') + 1
|
||||||
let end = start + len(t[2]) - 1
|
let end = start + len(t[2]) - 1
|
||||||
|
" TODO: why is there a one second delay the first time we get here?
|
||||||
exe "normal o" . t[0]
|
exe "normal o" . t[0]
|
||||||
call cursor(start, 1)
|
call cursor(start, 1)
|
||||||
exe t[1]
|
exe t[1]
|
||||||
@@ -716,3 +717,12 @@ one two
|
|||||||
|
|
||||||
close!
|
close!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_sub_beyond_end()
|
||||||
|
new
|
||||||
|
call setline(1, '#')
|
||||||
|
let @/ = '^#\n\zs'
|
||||||
|
s///e
|
||||||
|
call assert_equal('#', getline(1))
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
@@ -741,6 +741,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2236,
|
||||||
/**/
|
/**/
|
||||||
2235,
|
2235,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user