diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2020-02-29 15:27:17 +0100 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2020-09-09 21:22:21 +0200 |
commit | bc86f76c0a1d3234b749a105c9aae65f84c51320 (patch) | |
tree | c8930079e178c2a3233ef43602f7136d3f6981fb /src/nvim/buffer_updates.c | |
parent | 81fa107f595ee0392b5f004b86e4e8d41e49cc9e (diff) | |
download | rneovim-bc86f76c0a1d3234b749a105c9aae65f84c51320.tar.gz rneovim-bc86f76c0a1d3234b749a105c9aae65f84c51320.tar.bz2 rneovim-bc86f76c0a1d3234b749a105c9aae65f84c51320.zip |
api/buffer: add "on_bytes" callback to nvim_buf_attach
This implements byte-resolution updates of buffer changes.
Note: there is no promise that the buffer state is valid inside
the callback!
Diffstat (limited to 'src/nvim/buffer_updates.c')
-rw-r--r-- | src/nvim/buffer_updates.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/nvim/buffer_updates.c b/src/nvim/buffer_updates.c index e6393bf02c..1e7cc8520f 100644 --- a/src/nvim/buffer_updates.c +++ b/src/nvim/buffer_updates.c @@ -2,6 +2,7 @@ // it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com #include "nvim/buffer_updates.h" +#include "nvim/extmark.h" #include "nvim/memline.h" #include "nvim/api/private/helpers.h" #include "nvim/msgpack_rpc/channel.h" @@ -282,9 +283,9 @@ void buf_updates_send_changes(buf_T *buf, } void buf_updates_send_splice(buf_T *buf, - linenr_T start_line, colnr_T start_col, - linenr_T oldextent_line, colnr_T oldextent_col, - linenr_T newextent_line, colnr_T newextent_col) + int start_row, colnr_T start_col, bcount_t start_byte, + int old_row, colnr_T old_col, bcount_t old_byte, + int new_row, colnr_T new_col, bcount_t new_byte) { if (!buf_updates_active(buf)) { return; @@ -296,7 +297,7 @@ void buf_updates_send_splice(buf_T *buf, BufUpdateCallbacks cb = kv_A(buf->update_callbacks, i); bool keep = true; if (cb.on_bytes != LUA_NOREF) { - FIXED_TEMP_ARRAY(args, 8); + FIXED_TEMP_ARRAY(args, 11); // the first argument is always the buffer handle args.items[0] = BUFFER_OBJ(buf->handle); @@ -304,12 +305,15 @@ void buf_updates_send_splice(buf_T *buf, // next argument is b:changedtick args.items[1] = INTEGER_OBJ(buf_get_changedtick(buf)); - args.items[2] = INTEGER_OBJ(start_line); + args.items[2] = INTEGER_OBJ(start_row); args.items[3] = INTEGER_OBJ(start_col); - args.items[4] = INTEGER_OBJ(oldextent_line); - args.items[5] = INTEGER_OBJ(oldextent_col); - args.items[6] = INTEGER_OBJ(newextent_line); - args.items[7] = INTEGER_OBJ(newextent_col); + args.items[4] = INTEGER_OBJ(start_byte); + args.items[5] = INTEGER_OBJ(old_row); + args.items[6] = INTEGER_OBJ(old_col); + args.items[7] = INTEGER_OBJ(old_byte); + args.items[8] = INTEGER_OBJ(new_row); + args.items[9] = INTEGER_OBJ(new_col); + args.items[10] = INTEGER_OBJ(new_byte); textlock++; Object res = executor_exec_lua_cb(cb.on_bytes, "bytes", args, true, NULL); |