From b50ee4a8dc4306e4be78ac33fb74b21dc6be5538 Mon Sep 17 00:00:00 2001 From: Jaehwang Jung Date: Tue, 28 Feb 2023 07:09:12 +0900 Subject: fix(diff): adjust extmarks after diffput/diffget (#22440) Problem: on_bytes is not triggered by diffput/diffget if the line count does not change. --- src/nvim/diff.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index c5b28822d0..289939b2ca 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -31,6 +31,7 @@ #include "nvim/ex_cmds.h" #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" +#include "nvim/extmark.h" #include "nvim/extmark_defs.h" #include "nvim/fileio.h" #include "nvim/fold.h" @@ -3102,6 +3103,9 @@ static void diffgetput(const int addr_count, const int idx_cur, const int idx_fr if (buf_empty && (curbuf->b_ml.ml_line_count == 2)) { // Added the first line into an empty buffer, need to // delete the dummy empty line. + // This has a side effect of incrementing curbuf->deleted_bytes, + // which results in inaccurate reporting of the byte count of + // previous contents in buffer-update events. buf_empty = false; ml_delete((linenr_T)2, false); } @@ -3143,6 +3147,7 @@ static void diffgetput(const int addr_count, const int idx_cur, const int idx_fr } } } + extmark_adjust(curbuf, lnum, lnum + count - 1, (long)MAXLNUM, added, kExtmarkUndo); changed_lines(lnum, 0, lnum + count, added, true); if (did_free) { -- cgit