else /* delete characters between lines */
{
pos_T curpos;
+ int delete_last_line;
/* save deleted and changed lines for undo */
if (u_save((linenr_T)(curwin->w_cursor.lnum - 1),
(linenr_T)(curwin->w_cursor.lnum + oap->line_count)) == FAIL)
return FAIL;
+ delete_last_line = (oap->end.lnum == curbuf->b_ml.ml_line_count);
truncate_line(TRUE); /* delete from cursor to end of line */
curpos = curwin->w_cursor; /* remember curwin->w_cursor */
del_lines((long)(oap->line_count - 2), FALSE);
n = (oap->end.col + 1 - !oap->inclusive);
- if (oap->inclusive && oap->end.lnum == curbuf->b_ml.ml_line_count
+ if (oap->inclusive && delete_last_line
&& n > (int)STRLEN(ml_get(oap->end.lnum)))
{
/* Special case: gH<Del> deletes the last line. */