To: vim_dev@googlegroups.com Subject: Patch 8.1.0511 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.0511 Problem: ml_get error when calling a function with a range. Solution: Don't position the cursor after the last line. Files: src/userfunc.c, src/testdir/test_functions.vim *** ../vim-8.1.0510/src/userfunc.c 2018-10-25 13:31:33.833906872 +0200 --- src/userfunc.c 2018-11-04 23:38:59.813826045 +0100 *************** *** 3149,3154 **** --- 3149,3161 ---- { 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.col = 0; #ifdef FEAT_VIRTUALEDIT *** ../vim-8.1.0510/src/testdir/test_functions.vim 2018-10-07 18:43:02.524682045 +0200 --- src/testdir/test_functions.vim 2018-11-04 23:33:21.703374164 +0100 *************** *** 1119,1121 **** --- 1119,1140 ---- call assert_fails('call Fsandbox()', 'E48:') delfunc Fsandbox endfunc + + func EditAnotherFile() + let word = expand('') + 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 *** ../vim-8.1.0510/src/version.c 2018-11-04 14:40:42.347139567 +0100 --- src/version.c 2018-11-04 23:36:30.146573147 +0100 *************** *** 794,795 **** --- 794,797 ---- { /* Add new patch number below this line */ + /**/ + 511, /**/ -- Proverb: A nightingale that forgets the lyrics is a hummingbird. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///