To: vim_dev@googlegroups.com Subject: Patch 8.1.2236 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.2236 Problem: Ml_get error if pattern matches beyond last line. Solution: Adjust position if needed. (Christian Brabandt, closes #5139) Files: src/ex_cmds.c, src/testdir/test_substitute.vim *** ../vim-8.1.2235/src/ex_cmds.c 2019-10-26 12:22:58.712730053 +0200 --- src/ex_cmds.c 2019-10-31 04:12:37.961027612 +0100 *************** *** 3947,3952 **** --- 3947,3957 ---- 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) { sub_firstline = vim_strsave(ml_get(sub_firstlnum)); *** ../vim-8.1.2235/src/testdir/test_substitute.vim 2019-09-07 19:05:02.341280926 +0200 --- src/testdir/test_substitute.vim 2019-10-31 04:35:14.566693602 +0100 *************** *** 413,418 **** --- 413,419 ---- for t in a:tests let start = line('.') + 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] call cursor(start, 1) exe t[1] *************** *** 716,718 **** --- 717,728 ---- close! endfunc + + func Test_sub_beyond_end() + new + call setline(1, '#') + let @/ = '^#\n\zs' + s///e + call assert_equal('#', getline(1)) + bwipe! + endfunc *** ../vim-8.1.2235/src/version.c 2019-10-31 03:21:21.121403678 +0100 --- src/version.c 2019-10-31 04:10:59.513546788 +0100 *************** *** 743,744 **** --- 743,746 ---- { /* Add new patch number below this line */ + /**/ + 2236, /**/ -- "How is your new girlfriend?" "90-60-90 man!" "What, pale purple?" /// 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 ///