Mercurial > vim
comparison src/register.c @ 24790:14b86681e6e6 v8.2.2933
patch 8.2.2933: when 'clipboard' is "unnamed" zp does not work correctly
Commit: https://github.com/vim/vim/commit/6e0b553fa12fc5ad5d8ee3d8457e7cb16f38b56f
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jun 4 17:11:47 2021 +0200
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 #8301, closes #8317)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 04 Jun 2021 17:15:03 +0200 |
parents | 1ce39e257f1b |
children | 91c42289cbe1 |
comparison
equal
deleted
inserted
replaced
24789:dcb034bff83a | 24790:14b86681e6e6 |
---|---|
2834 int append = FALSE; // append to last line in register | 2834 int append = FALSE; // append to last line in register |
2835 char_u *s; | 2835 char_u *s; |
2836 char_u **ss; | 2836 char_u **ss; |
2837 char_u **pp; | 2837 char_u **pp; |
2838 long maxlen; | 2838 long maxlen; |
2839 int charlen; | |
2839 | 2840 |
2840 if (y_ptr->y_array == NULL) // NULL means empty register | 2841 if (y_ptr->y_array == NULL) // NULL means empty register |
2841 y_ptr->y_size = 0; | 2842 y_ptr->y_size = 0; |
2842 | 2843 |
2843 if (yank_type == MAUTO) | 2844 if (yank_type == MAUTO) |
2892 // Find the end of each line and save it into the array. | 2893 // Find the end of each line and save it into the array. |
2893 if (str_list) | 2894 if (str_list) |
2894 { | 2895 { |
2895 for (ss = (char_u **) str; *ss != NULL; ++ss, ++lnum) | 2896 for (ss = (char_u **) str; *ss != NULL; ++ss, ++lnum) |
2896 { | 2897 { |
2898 charlen = MB_CHARLEN(*ss); | |
2897 i = (long)STRLEN(*ss); | 2899 i = (long)STRLEN(*ss); |
2898 pp[lnum] = vim_strnsave(*ss, i); | 2900 pp[lnum] = vim_strnsave(*ss, i); |
2899 if (i > maxlen) | 2901 if (charlen > maxlen) |
2900 maxlen = i; | 2902 maxlen = charlen; |
2901 } | 2903 } |
2902 } | 2904 } |
2903 else | 2905 else |
2904 { | 2906 { |
2905 for (start = 0; start < len + extraline; start += i + 1) | 2907 for (start = 0; start < len + extraline; start += i + 1) |
2906 { | 2908 { |
2909 charlen = 0; | |
2907 for (i = start; i < len; ++i) // find the end of the line | 2910 for (i = start; i < len; ++i) // find the end of the line |
2908 if (str[i] == '\n') | 2911 if (str[i] == '\n') |
2909 break; | 2912 break; |
2910 i -= start; // i is now length of line | 2913 i -= start; // i is now length of line |
2911 if (i > maxlen) | 2914 if (start < len) |
2912 maxlen = i; | 2915 charlen = mb_charlen_len(str + start, i); |
2916 if (charlen > maxlen) | |
2917 maxlen = charlen; | |
2913 if (append) | 2918 if (append) |
2914 { | 2919 { |
2915 --lnum; | 2920 --lnum; |
2916 extra = (int)STRLEN(y_ptr->y_array[lnum]); | 2921 extra = (int)STRLEN(y_ptr->y_array[lnum]); |
2917 } | 2922 } |