summaryrefslogtreecommitdiffstats
path: root/src/ex_cmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ex_cmds.c')
-rw-r--r--src/ex_cmds.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index fc692e3235..a7f80a80a8 100644
--- 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));