updated for version 7.0049
diff --git a/src/edit.c b/src/edit.c
index 175256e..a889736 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -5151,7 +5151,9 @@
if (n > 0)
{
lnum = curwin->w_cursor.lnum;
- if (lnum <= 1)
+ /* This fails if the cursor is already in the first line or the count
+ * is larger than the line number and '-' is in 'cpoptions' */
+ if (lnum <= 1 || (n >= lnum && vim_strchr(p_cpo, CPO_MINUS) != NULL))
return FAIL;
if (n >= lnum)
lnum = 1;
@@ -5212,7 +5214,11 @@
/* Move to last line of fold, will fail if it's the end-of-file. */
(void)hasFolding(lnum, NULL, &lnum);
#endif
- if (lnum >= curbuf->b_ml.ml_line_count)
+ /* This fails if the cursor is already in the last line or would move
+ * beyound the last line and '-' is in 'cpoptions' */
+ if (lnum >= curbuf->b_ml.ml_line_count
+ || (lnum + n > curbuf->b_ml.ml_line_count
+ && vim_strchr(p_cpo, CPO_MINUS) != NULL))
return FAIL;
if (lnum + n >= curbuf->b_ml.ml_line_count)
lnum = curbuf->b_ml.ml_line_count;