aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Vigouroux <tomvig38@gmail.com>2021-05-17 20:24:11 +0200
committerThomas Vigouroux <tomvig38@gmail.com>2021-05-18 19:31:56 +0200
commit237175cf20af5cac6d2e02560a65fd4590d2080c (patch)
tree0a5b0ceede0f6c2185df371d80ab3ce65bbd868f
parentc46d9814619cee5183ea08989352d72fb9aaea5a (diff)
downloadrneovim-237175cf20af5cac6d2e02560a65fd4590d2080c.tar.gz
rneovim-237175cf20af5cac6d2e02560a65fd4590d2080c.tar.bz2
rneovim-237175cf20af5cac6d2e02560a65fd4590d2080c.zip
fix(bufupdate): send events when inserting with virtualedit
Problem first raised https://github.com/nvim-treesitter/nvim-treesitter/issues/1304
-rw-r--r--src/nvim/cursor.c5
-rw-r--r--test/functional/lua/buffer_updates_spec.lua20
2 files changed, 23 insertions, 2 deletions
diff --git a/src/nvim/cursor.c b/src/nvim/cursor.c
index 74a6f77a6d..5d2210dc7d 100644
--- a/src/nvim/cursor.c
+++ b/src/nvim/cursor.c
@@ -14,6 +14,7 @@
#include "nvim/misc1.h"
#include "nvim/move.h"
#include "nvim/screen.h"
+#include "nvim/extmark.h"
#include "nvim/state.h"
#include "nvim/vim.h"
#include "nvim/ascii.h"
@@ -181,7 +182,7 @@ static int coladvance2(
memset(newline + idx, ' ', (size_t)correct);
ml_replace(pos->lnum, newline, false);
- changed_bytes(pos->lnum, (colnr_T)idx);
+ inserted_bytes(pos->lnum, (colnr_T)idx, 0, correct);
idx += correct;
col = wcol;
} else {
@@ -206,7 +207,7 @@ static int coladvance2(
memcpy(newline + idx + csize, line + idx + 1, n);
ml_replace(pos->lnum, newline, false);
- changed_bytes(pos->lnum, idx);
+ inserted_bytes(pos->lnum, idx, 1, csize);
idx += (csize - 1 + correct);
col += correct;
}
diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua
index 5bfab1d52d..54e10fabd6 100644
--- a/test/functional/lua/buffer_updates_spec.lua
+++ b/test/functional/lua/buffer_updates_spec.lua
@@ -936,6 +936,26 @@ describe('lua: nvim_buf_attach on_bytes', function()
}
end)
+ it("virtual edit", function ()
+ local check_events = setup_eventcheck(verify, { "", " " })
+
+ meths.set_option("virtualedit", "all")
+
+ feed [[<Right><Right>iab<ESC>]]
+
+ check_events {
+ { "test1", "bytes", 1, 3, 0, 0, 0, 0, 0, 0, 0, 2, 2 };
+ { "test1", "bytes", 1, 4, 0, 2, 2, 0, 0, 0, 0, 2, 2 };
+ }
+
+ feed [[j<Right><Right>iab<ESC>]]
+
+ check_events {
+ { "test1", "bytes", 1, 5, 1, 0, 5, 0, 1, 1, 0, 8, 8 };
+ { "test1", "bytes", 1, 6, 1, 5, 10, 0, 0, 0, 0, 2, 2 };
+ }
+ end)
+
it("block visual paste", function()
local check_events = setup_eventcheck(verify, {"AAA",
"BBB",