fix(buffer_updates): handle :delete of the very last line in buffer

This commit is contained in:
Björn Linse
2021-10-07 19:35:49 +02:00
parent b9a35ec7a4
commit 8335e26b2d
2 changed files with 30 additions and 1 deletions

View File

@@ -413,7 +413,11 @@ void deleted_lines(linenr_T lnum, long count)
/// be triggered to display the cursor.
void deleted_lines_mark(linenr_T lnum, long count)
{
mark_adjust(lnum, (linenr_T)(lnum + count - 1), (long)MAXLNUM, -count,
// if we deleted the entire buffer, we need to implicity add a new empty line
bool made_empty = (count > 0) && curbuf->b_ml.ml_flags & ML_EMPTY;
mark_adjust(lnum, (linenr_T)(lnum + count - 1), (long)MAXLNUM,
-count + (made_empty?1:0),
kExtmarkUndo);
changed_lines(lnum, 0, lnum + count, -count, true);
}