File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1119,3 +1119,22 @@ func Test_func_sandbox()
11191119 call assert_fails (' call Fsandbox()' , ' E48:' )
11201120 delfunc Fsandbox
11211121endfunc
1122+
1123+ func EditAnotherFile ()
1124+ let word = expand (' <cword>' )
1125+ edit Xfuncrange2
1126+ endfunc
1127+
1128+ func Test_func_range_with_edit ()
1129+ " Define a function that edits another buffer, then call it with a range that
1130+ " is invalid in that buffer.
1131+ call writefile ([' just one line' ], ' Xfuncrange2' )
1132+ new
1133+ call setline (1 , range (10 ))
1134+ write Xfuncrange1
1135+ call assert_fails (' 5,8call EditAnotherFile()' , ' E16:' )
1136+
1137+ call delete (' Xfuncrange1' )
1138+ call delete (' Xfuncrange2' )
1139+ bwipe!
1140+ endfunc
Original file line number Diff line number Diff line change @@ -3149,6 +3149,13 @@ ex_call(exarg_T *eap)
31493149 {
31503150 if (!eap -> skip && eap -> addr_count > 0 )
31513151 {
3152+ if (lnum > curbuf -> b_ml .ml_line_count )
3153+ {
3154+ // If the function deleted lines or switched to another buffer
3155+ // the line number may become invalid.
3156+ EMSG (_ (e_invrange ));
3157+ break ;
3158+ }
31523159 curwin -> w_cursor .lnum = lnum ;
31533160 curwin -> w_cursor .col = 0 ;
31543161#ifdef FEAT_VIRTUALEDIT
Original file line number Diff line number Diff line change @@ -792,6 +792,8 @@ static char *(features[]) =
792792
793793static int included_patches [] =
794794{ /* Add new patch number below this line */
795+ /**/
796+ 511 ,
795797/**/
796798 510 ,
797799/**/
You can’t perform that action at this time.
0 commit comments