Manually zero out deleted_bytes2 when substituting and joining lines

This commit is contained in:
chentau
2021-06-11 00:41:54 -07:00
parent 1df8a34a7b
commit 1c962401a1
3 changed files with 36 additions and 0 deletions

View File

@@ -4230,6 +4230,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

View File

@@ -3977,6 +3977,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:

View File

@@ -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"