diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2019-08-04 12:22:22 +0200 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2019-08-06 20:24:36 +0200 |
commit | c0993ed3433ef4111a39e59642d15b15261e8b68 (patch) | |
tree | cb2a4225d70dec491f96412f96ebcb7c5a391e9a /src/nvim/api/buffer.c | |
parent | b0e26199ec02c9b392af6161522004c55db0441f (diff) | |
download | rneovim-c0993ed3433ef4111a39e59642d15b15261e8b68.tar.gz rneovim-c0993ed3433ef4111a39e59642d15b15261e8b68.tar.bz2 rneovim-c0993ed3433ef4111a39e59642d15b15261e8b68.zip |
lua: support getting UTF-32 and UTF-16 sizes of replaced text
Diffstat (limited to 'src/nvim/api/buffer.c')
-rw-r--r-- | src/nvim/api/buffer.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index 497b4ae9a4..c6f82e9d85 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -109,9 +109,11 @@ String buffer_get_line(Buffer buffer, Integer index, Error *err) /// `nvim_buf_lines_event`. Otherwise, the first notification will be /// a `nvim_buf_changedtick_event`. Not used for lua callbacks. /// @param opts Optional parameters. -/// `on_lines`: lua callback received on change. +/// `on_lines`: lua callback received on change. /// `on_changedtick`: lua callback received on changedtick /// increment without text change. +/// `utf_sizes`: include UTF-32 and UTF-16 size of +/// the replaced region. /// See |api-buffer-updates-lua| for more information /// @param[out] err Error details, if any /// @return False when updates couldn't be enabled because the buffer isn't @@ -156,6 +158,12 @@ Boolean nvim_buf_attach(uint64_t channel_id, } cb.on_detach = v->data.luaref; v->data.integer = LUA_NOREF; + } else if (is_lua && strequal("utf_sizes", k.data)) { + if (v->type != kObjectTypeBoolean) { + api_set_error(err, kErrorTypeValidation, "utf_sizes must be boolean"); + goto error; + } + cb.utf_sizes = v->data.boolean; } else { api_set_error(err, kErrorTypeValidation, "unexpected key: %s", k.data); goto error; @@ -1196,6 +1204,7 @@ Dictionary nvim__buf_stats(Buffer buffer, Error *err) // NB: this should be zero at any time API functions are called, // this exists to debug issues PUT(rv, "dirty_bytes", INTEGER_OBJ((Integer)buf->deleted_bytes)); + return rv; } |