mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
patch 8.1.0511: ml_get error when calling a function with a range
Problem: ml_get error when calling a function with a range. Solution: Don't position the cursor after the last line.
This commit is contained in:
@@ -1119,3 +1119,22 @@ func Test_func_sandbox()
|
|||||||
call assert_fails('call Fsandbox()', 'E48:')
|
call assert_fails('call Fsandbox()', 'E48:')
|
||||||
delfunc Fsandbox
|
delfunc Fsandbox
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func EditAnotherFile()
|
||||||
|
let word = expand('<cword>')
|
||||||
|
edit Xfuncrange2
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_func_range_with_edit()
|
||||||
|
" Define a function that edits another buffer, then call it with a range that
|
||||||
|
" is invalid in that buffer.
|
||||||
|
call writefile(['just one line'], 'Xfuncrange2')
|
||||||
|
new
|
||||||
|
call setline(1, range(10))
|
||||||
|
write Xfuncrange1
|
||||||
|
call assert_fails('5,8call EditAnotherFile()', 'E16:')
|
||||||
|
|
||||||
|
call delete('Xfuncrange1')
|
||||||
|
call delete('Xfuncrange2')
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
@@ -3149,6 +3149,13 @@ ex_call(exarg_T *eap)
|
|||||||
{
|
{
|
||||||
if (!eap->skip && eap->addr_count > 0)
|
if (!eap->skip && eap->addr_count > 0)
|
||||||
{
|
{
|
||||||
|
if (lnum > curbuf->b_ml.ml_line_count)
|
||||||
|
{
|
||||||
|
// If the function deleted lines or switched to another buffer
|
||||||
|
// the line number may become invalid.
|
||||||
|
EMSG(_(e_invrange));
|
||||||
|
break;
|
||||||
|
}
|
||||||
curwin->w_cursor.lnum = lnum;
|
curwin->w_cursor.lnum = lnum;
|
||||||
curwin->w_cursor.col = 0;
|
curwin->w_cursor.col = 0;
|
||||||
#ifdef FEAT_VIRTUALEDIT
|
#ifdef FEAT_VIRTUALEDIT
|
||||||
|
@@ -792,6 +792,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 */
|
||||||
|
/**/
|
||||||
|
511,
|
||||||
/**/
|
/**/
|
||||||
510,
|
510,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user