aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2025-02-09 08:26:48 +0800
committerzeertzjq <zeertzjq@outlook.com>2025-02-09 08:30:32 +0800
commit00bce2723fb3b6e36bb7b0b0570c33ffc9508b78 (patch)
tree05c38e02ccf0f15918b378f197514a2b55bedd22
parent9afc1f0f3b1533bdfa6dd821bbfa93c6858016c6 (diff)
downloadrneovim-00bce2723fb3b6e36bb7b0b0570c33ffc9508b78.tar.gz
rneovim-00bce2723fb3b6e36bb7b0b0570c33ffc9508b78.tar.bz2
rneovim-00bce2723fb3b6e36bb7b0b0570c33ffc9508b78.zip
vim-patch:8.2.2935: calculating register width is not always needed
Problem: Calculating register width is not always needed. (Christian Brabandt) Solution: Only calculate the width when the type is MBLOCK. https://github.com/vim/vim/commit/6c4c404c580fadd69e39297a6cb4b214f2fcb6d6 Co-authored-by: Bram Moolenaar <Bram@vim.org>
-rw-r--r--src/nvim/ops.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index cb86d194b8..6c15d9a555 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -5236,10 +5236,11 @@ 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, (size_t)charlen);
+ pp[lnum] = cstr_to_string(*ss);
+ if (yank_type == kMTBlockWise) {
+ size_t charlen = mb_string2cells(*ss);
+ maxlen = MAX(maxlen, charlen);
+ }
}
} else {
size_t line_len;
@@ -5252,7 +5253,9 @@ static void str_to_reg(yankreg_T *y_ptr, MotionType yank_type, const char *str,
if (*line_end == '\n') {
break;
}
- charlen += utf_ptr2cells_len(line_end, (int)(end - line_end));
+ if (yank_type == kMTBlockWise) {
+ charlen += utf_ptr2cells_len(line_end, (int)(end - line_end));
+ }
}
assert(line_end - start >= 0);
line_len = (size_t)(line_end - start);