Mercurial > vim
diff src/ex_cmds.c @ 18483:54e5fa1f9cfc v8.1.2236
patch 8.1.2236: ml_get error if pattern matches beyond last line
Commit: https://github.com/vim/vim/commit/bb26596242fa7db477e2cd706dd99f9a426b5f71
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Oct 31 04:38:36 2019 +0100
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 https://github.com/vim/vim/issues/5139)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 31 Oct 2019 04:45:03 +0100 |
parents | b026f4524f25 |
children | e5ef5d820b5b |
line wrap: on
line diff
--- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -3947,6 +3947,11 @@ do_sub(exarg_T *eap) 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));