aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2021-10-07 20:13:15 +0200
committerGitHub <noreply@github.com>2021-10-07 20:13:15 +0200
commit206f4429c600620c7dad7225d1b128cbd5b35f6e (patch)
tree84edde4183064e618cdeb1dba42b808c755dd8b1 /src
parentb9a35ec7a4829c442ac8b5412e4d51558af4046b (diff)
parent8335e26b2d0226f5b50fb4a9c4e6d37919aeb212 (diff)
downloadrneovim-206f4429c600620c7dad7225d1b128cbd5b35f6e.tar.gz
rneovim-206f4429c600620c7dad7225d1b128cbd5b35f6e.tar.bz2
rneovim-206f4429c600620c7dad7225d1b128cbd5b35f6e.zip
Merge pull request #15945 from bfredl/emptydelete
fix(buffer_updates): handle :delete of the very last line in buffer
Diffstat (limited to 'src')
-rw-r--r--src/nvim/change.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/nvim/change.c b/src/nvim/change.c
index 7f702d888e..2450c56838 100644
--- a/src/nvim/change.c
+++ b/src/nvim/change.c
@@ -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);
}