Mercurial > vim
comparison src/register.c @ 24794:fd245e5d4585 v8.2.2935
patch 8.2.2935: calculating register width is not always needed
Commit: https://github.com/vim/vim/commit/6c4c404c580fadd69e39297a6cb4b214f2fcb6d6
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jun 4 19:17:07 2021 +0200
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 04 Jun 2021 19:30:03 +0200 |
parents | 91c42289cbe1 |
children | f1121eb17e14 |
comparison
equal
deleted
inserted
replaced
24793:83d41b2de004 | 24794:fd245e5d4585 |
---|---|
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; | |
2840 | 2839 |
2841 if (y_ptr->y_array == NULL) // NULL means empty register | 2840 if (y_ptr->y_array == NULL) // NULL means empty register |
2842 y_ptr->y_size = 0; | 2841 y_ptr->y_size = 0; |
2843 | 2842 |
2844 if (yank_type == MAUTO) | 2843 if (yank_type == MAUTO) |
2893 // Find the end of each line and save it into the array. | 2892 // Find the end of each line and save it into the array. |
2894 if (str_list) | 2893 if (str_list) |
2895 { | 2894 { |
2896 for (ss = (char_u **) str; *ss != NULL; ++ss, ++lnum) | 2895 for (ss = (char_u **) str; *ss != NULL; ++ss, ++lnum) |
2897 { | 2896 { |
2898 charlen = MB_CHARLEN(*ss); | 2897 pp[lnum] = vim_strsave(*ss); |
2899 i = (long)STRLEN(*ss); | 2898 if (type == MBLOCK) |
2900 pp[lnum] = vim_strnsave(*ss, i); | 2899 { |
2901 if (charlen > maxlen) | 2900 int charlen = mb_string2cells(*ss, -1); |
2902 maxlen = charlen; | 2901 |
2902 if (charlen > maxlen) | |
2903 maxlen = charlen; | |
2904 } | |
2903 } | 2905 } |
2904 } | 2906 } |
2905 else | 2907 else |
2906 { | 2908 { |
2907 for (start = 0; start < len + extraline; start += i + 1) | 2909 for (start = 0; start < len + extraline; start += i + 1) |
2908 { | 2910 { |
2909 charlen = 0; | 2911 int charlen = 0; |
2912 | |
2910 for (i = start; i < len; ++i) // find the end of the line | 2913 for (i = start; i < len; ++i) // find the end of the line |
2911 { | 2914 { |
2912 if (str[i] == '\n') | 2915 if (str[i] == '\n') |
2913 break; | 2916 break; |
2914 charlen += mb_ptr2cells_len(str + i, len - i); | 2917 if (type == MBLOCK) |
2918 charlen += mb_ptr2cells_len(str + i, len - i); | |
2915 } | 2919 } |
2916 i -= start; // i is now length of line | 2920 i -= start; // i is now length of line |
2917 if (charlen > maxlen) | 2921 if (charlen > maxlen) |
2918 maxlen = charlen; | 2922 maxlen = charlen; |
2919 if (append) | 2923 if (append) |