neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 9dc5e2100f679b7523225d23967fc1c87005877b
parent 59edd7c88a13d793501b88c55803da8a0ba7c739
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Sun,  9 Feb 2025 08:11:04 +0800

vim-patch:8.2.2933: when 'clipboard' is "unnamed" zp does not work correctly

Problem:    When 'clipboard' is "unnamed" zp and zP do not work correctly.
Solution:   Pass -1 to str_to_reg() and fix computing the character width
            instead of using the byte length. (Christian Brabandt,
            closes vim/vim#8301, closes vim/vim#8317)

https://github.com/vim/vim/commit/6e0b553fa12fc5ad5d8ee3d8457e7cb16f38b56f

Co-authored-by: Bram Moolenaar <Bram@vim.org>

Diffstat:
Msrc/nvim/ops.c | 10+++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/nvim/ops.c b/src/nvim/ops.c @@ -5236,9 +5236,10 @@ static void str_to_reg(yankreg_T *y_ptr, MotionType yank_type, const char *str, // Find the end of each line and save it into the array. if (str_list) { for (char **ss = (char **)str; *ss != NULL; ss++, lnum++) { + int charlen = mb_charlen(*ss); size_t ss_len = strlen(*ss); pp[lnum] = cbuf_to_string(*ss, ss_len); - maxlen = MAX(maxlen, ss_len); + maxlen = MAX(maxlen, (size_t)charlen); } } else { size_t line_len; @@ -5246,8 +5247,11 @@ static void str_to_reg(yankreg_T *y_ptr, MotionType yank_type, const char *str, start < end + extraline; start += line_len + 1, lnum++) { assert(end - start >= 0); - line_len = (size_t)((char *)xmemscan(start, '\n', (size_t)(end - start)) - start); - maxlen = MAX(maxlen, line_len); + const char *line_end = xmemscan(start, '\n', (size_t)(end - start)); + assert(line_end - start >= 0); + line_len = (size_t)(line_end - start); + int charlen = start < end ? mb_charlen_len(start, (int)line_len) : 0; + maxlen = MAX(maxlen, (size_t)charlen); // When appending, copy the previous line and free it after. size_t extra = append ? pp[--lnum].size : 0;