aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2021-06-29 15:31:23 +0200
committerGitHub <noreply@github.com>2021-06-29 15:31:23 +0200
commitf8990870ffd86ff36cc86e23b82b74b1a764b525 (patch)
tree3f40c4cb4e02ebc2fce2fe92d7d34bbcfdb70051
parentf83c25942dd8b94ad5218ce78b9e6fb86d2f0358 (diff)
parent1c962401a10911e2766a5290f9b8171558c8fb40 (diff)
downloadrneovim-f8990870ffd86ff36cc86e23b82b74b1a764b525.tar.gz
rneovim-f8990870ffd86ff36cc86e23b82b74b1a764b525.tar.bz2
rneovim-f8990870ffd86ff36cc86e23b82b74b1a764b525.zip
Merge pull request #14335 from chentau/extmark_delbytes
Extmarks: manually zero out `curbuf->deleted_bytes2` on substitute and join
-rw-r--r--src/nvim/ex_cmds.c2
-rw-r--r--src/nvim/ops.c1
-rw-r--r--test/functional/lua/buffer_updates_spec.lua33
3 files changed, 36 insertions, 0 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index c399d47b7e..4af7794317 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -4237,6 +4237,8 @@ skip:
}
}
+ curbuf->deleted_bytes2 = 0;
+
if (first_line != 0) {
/* Need to subtract the number of added lines from "last_line" to get
* the line number before the change (same as adding the number of
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index f2f6803665..04a8fc8499 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -3992,6 +3992,7 @@ int do_join(size_t count,
del_lines((long)count - 1, false);
curwin->w_cursor.lnum = t;
curbuf_splice_pending--;
+ curbuf->deleted_bytes2 = 0;
/*
* Set the cursor column:
diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua
index 1b2c21783e..a5b613f0b2 100644
--- a/test/functional/lua/buffer_updates_spec.lua
+++ b/test/functional/lua/buffer_updates_spec.lua
@@ -1001,6 +1001,39 @@ describe('lua: nvim_buf_attach on_bytes', function()
}
end)
+ it("flushes delbytes on substitute", function()
+ local check_events = setup_eventcheck(verify, {"AAA", "BBB", "CCC"})
+
+ feed("gg0")
+ command("s/AAA/GGG/")
+
+ check_events {
+ { "test1", "bytes", 1, 3, 0, 0, 0, 0, 3, 3, 0, 3, 3 };
+ }
+
+ -- check that byte updates for :delete (which uses curbuf->deleted_bytes2)
+ -- are correct
+ command("delete")
+ check_events {
+ { "test1", "bytes", 1, 4, 0, 0, 0, 1, 0, 4, 0, 0, 0 };
+ }
+ end)
+
+ it("flushes delbytes on join", function()
+ local check_events = setup_eventcheck(verify, {"AAA", "BBB", "CCC"})
+
+ feed("gg0J")
+
+ check_events {
+ { "test1", "bytes", 1, 3, 0, 3, 3, 1, 0, 1, 0, 1, 1 };
+ }
+
+ command("delete")
+ check_events {
+ { "test1", "bytes", 1, 5, 0, 0, 0, 1, 0, 8, 0, 0, 0 };
+ }
+ end)
+
teardown(function()
os.remove "Xtest-reload"
os.remove "Xtest-undofile"