aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2025-02-09 08:11:04 +0800
committerzeertzjq <zeertzjq@outlook.com>2025-02-09 08:19:25 +0800
commit9dc5e2100f679b7523225d23967fc1c87005877b (patch)
tree123c2ae1483af511157d7f4466ef9a2fb73ac88e
parent59edd7c88a13d793501b88c55803da8a0ba7c739 (diff)
downloadrneovim-9dc5e2100f679b7523225d23967fc1c87005877b.tar.gz
rneovim-9dc5e2100f679b7523225d23967fc1c87005877b.tar.bz2
rneovim-9dc5e2100f679b7523225d23967fc1c87005877b.zip
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>
-rw-r--r--src/nvim/ops.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index d51b4cc88b..81ce541df4 100644
--- 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;