From 7159a0192b3fff4b5a6c380efcf9cdb276837d41 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 10 Aug 2025 19:17:22 -0400 Subject: [PATCH] vim-patch:8.1.1711: listener callback called at the wrong moment Problem: Listener callback called at the wrong moment Solution: Invoke listeners before calling ml_delete_int(). (closes vim/vim#4657) https://github.com/vim/vim/commit/acf7544cf62227972eeb063d6d9ecddaa5682a73 Co-authored-by: Bram Moolenaar (cherry picked from commit 750c350be86bb9dcf09fa8fc7f2978b127cbcae5) --- src/nvim/memline.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 6067413a43..c417c3f875 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -2542,6 +2542,10 @@ int ml_replace_buf(buf_T *buf, linenr_T lnum, char *line, bool copy, bool noallo int ml_delete(linenr_T lnum, bool message) { ml_flush_line(curbuf, false); + if (lnum < 1 || lnum > curbuf->b_ml.ml_line_count) { + return FAIL; + } + return ml_delete_int(curbuf, lnum, message); } @@ -2560,10 +2564,6 @@ int ml_delete_buf(buf_T *buf, linenr_T lnum, bool message) static int ml_delete_int(buf_T *buf, linenr_T lnum, bool message) { - if (lnum < 1 || lnum > buf->b_ml.ml_line_count) { - return FAIL; - } - if (lowest_marked && lowest_marked > lnum) { lowest_marked--; }