diff options
author | bfredl <bjorn.linse@gmail.com> | 2022-09-13 23:17:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-13 23:17:11 +0200 |
commit | 1e5daed67693f88d3ad515cf9e2d2f6d29c48a08 (patch) | |
tree | e197cd160981844600db1972f139f922eecc74d7 /src/nvim/memline.c | |
parent | a8c9e721d91efe4730db78c1115261fc128dca68 (diff) | |
parent | 25e4af439f3b5620406776ca77417d897097a3e9 (diff) | |
download | rneovim-1e5daed67693f88d3ad515cf9e2d2f6d29c48a08.tar.gz rneovim-1e5daed67693f88d3ad515cf9e2d2f6d29c48a08.tar.bz2 rneovim-1e5daed67693f88d3ad515cf9e2d2f6d29c48a08.zip |
Merge pull request #20164 from bfredl/luanull
fix(lua): make vim.str_utfindex and vim.str_byteindex handle NUL bytes
Diffstat (limited to 'src/nvim/memline.c')
-rw-r--r-- | src/nvim/memline.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 13fc2b43ec..6f283701c1 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -2252,8 +2252,9 @@ void ml_add_deleted_len_buf(buf_T *buf, char_u *ptr, ssize_t len) if (inhibit_delete_count) { return; } - if (len == -1) { - len = (ssize_t)STRLEN(ptr); + ssize_t maxlen = (ssize_t)STRLEN(ptr); + if (len == -1 || len > maxlen) { + len = maxlen; } curbuf->deleted_bytes += (size_t)len + 1; curbuf->deleted_bytes2 += (size_t)len + 1; |