aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2021-10-07 20:52:10 +0200
committerGitHub <noreply@github.com>2021-10-07 20:52:10 +0200
commit2d206d5ab2725791e9f2ce40df3133aed7c48a70 (patch)
tree6aa47e2ae0966e6304251b343e495e9028a7d525
parentfe608750a9473ad859e31644fad5a8deae518f2a (diff)
parent54b2c6800e9809b749381890da0f98f63f5fe53b (diff)
downloadrneovim-2d206d5ab2725791e9f2ce40df3133aed7c48a70.tar.gz
rneovim-2d206d5ab2725791e9f2ce40df3133aed7c48a70.tar.bz2
rneovim-2d206d5ab2725791e9f2ce40df3133aed7c48a70.zip
Merge pull request #15946 from bfredl/issue-12861
fix(buffer_updates): make lockmarks not affect extmarks and buffer updates
-rw-r--r--src/nvim/mark.c7
-rw-r--r--test/functional/lua/buffer_updates_spec.lua42
2 files changed, 46 insertions, 3 deletions
diff --git a/src/nvim/mark.c b/src/nvim/mark.c
index edec85c0b2..835c2adbe5 100644
--- a/src/nvim/mark.c
+++ b/src/nvim/mark.c
@@ -1036,9 +1036,10 @@ static void mark_adjust_internal(linenr_T line1, linenr_T line2, long amount, lo
}
sign_mark_adjust(line1, line2, amount, amount_after);
- if (op != kExtmarkNOOP) {
- extmark_adjust(curbuf, line1, line2, amount, amount_after, op);
- }
+ }
+
+ if (op != kExtmarkNOOP) {
+ extmark_adjust(curbuf, line1, line2, amount, amount_after, op);
}
// previous context mark
diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua
index 42b3d86eb0..83ed7394b0 100644
--- a/test/functional/lua/buffer_updates_spec.lua
+++ b/test/functional/lua/buffer_updates_spec.lua
@@ -1088,6 +1088,48 @@ describe('lua: nvim_buf_attach on_bytes', function()
}
end)
+ local function test_lockmarks(mode)
+ local description = (mode ~= "") and mode or "(baseline)"
+ it("test_lockmarks " .. description .. " %delete _", function()
+ local check_events = setup_eventcheck(verify, {"AAA", "BBB", "CCC"})
+
+ command(mode .. " %delete _")
+ check_events {
+ { "test1", "bytes", 1, 3, 0, 0, 0, 3, 0, 12, 1, 0, 1 };
+ }
+ end)
+
+ it("test_lockmarks " .. description .. " append()", function()
+ local check_events = setup_eventcheck(verify)
+
+ command(mode .. " call append(0, 'CCC')")
+ check_events {
+ { "test1", "bytes", 1, 2, 0, 0, 0, 0, 0, 0, 1, 0, 4 };
+ }
+
+ command(mode .. " call append(1, 'BBBB')")
+ check_events {
+ { "test1", "bytes", 1, 3, 1, 0, 4, 0, 0, 0, 1, 0, 5 };
+ }
+
+ command(mode .. " call append(2, '')")
+ check_events {
+ { "test1", "bytes", 1, 4, 2, 0, 9, 0, 0, 0, 1, 0, 1 };
+ }
+
+ command(mode .. " $delete _")
+ check_events {
+ { "test1", "bytes", 1, 5, 3, 0, 10, 1, 0, 1, 0, 0, 0 };
+ }
+
+ eq("CCC|BBBB|", table.concat(meths.buf_get_lines(0, 0, -1, true), "|"))
+ end)
+ end
+
+ -- check that behavior is identical with and without "lockmarks"
+ test_lockmarks ""
+ test_lockmarks "lockmarks"
+
teardown(function()
os.remove "Xtest-reload"
os.remove "Xtest-undofile"