Mercurial > vim
comparison src/screen.c @ 17742:a51ccadd0dca v8.1.1868
patch 8.1.1868: multi-byte chars in 'listchars' fail with 'linebreak' set
commit https://github.com/vim/vim/commit/69cbbecf548f390197259ca30cfe147c3e59ce5a
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Aug 17 14:10:56 2019 +0200
patch 8.1.1868: multi-byte chars in 'listchars' fail with 'linebreak' set
Problem: Multibyte characters in 'listchars' don't work correctly if
'linebreak' is also enabled. (Martin Tournoij)
Solution: Make it work correctly. (Christian Brabandt, closes #4822,
closes #4812)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 17 Aug 2019 14:15:03 +0200 |
parents | 03dcb660c4e8 |
children | 4bd21046902b |
comparison
equal
deleted
inserted
replaced
17741:5b329791d09a | 17742:a51ccadd0dca |
---|---|
4889 /* only adjust the tab_len, when at the first column | 4889 /* only adjust the tab_len, when at the first column |
4890 * after the showbreak value was drawn */ | 4890 * after the showbreak value was drawn */ |
4891 if (*p_sbr != NUL && vcol == vcol_sbr && wp->w_p_wrap) | 4891 if (*p_sbr != NUL && vcol == vcol_sbr && wp->w_p_wrap) |
4892 vcol_adjusted = vcol - MB_CHARLEN(p_sbr); | 4892 vcol_adjusted = vcol - MB_CHARLEN(p_sbr); |
4893 #endif | 4893 #endif |
4894 /* tab amount depends on current column */ | 4894 // tab amount depends on current column |
4895 #ifdef FEAT_VARTABS | 4895 #ifdef FEAT_VARTABS |
4896 tab_len = tabstop_padding(vcol_adjusted, | 4896 tab_len = tabstop_padding(vcol_adjusted, |
4897 wp->w_buffer->b_p_ts, | 4897 wp->w_buffer->b_p_ts, |
4898 wp->w_buffer->b_p_vts_array) - 1; | 4898 wp->w_buffer->b_p_vts_array) - 1; |
4899 #else | 4899 #else |
4902 #endif | 4902 #endif |
4903 | 4903 |
4904 #ifdef FEAT_LINEBREAK | 4904 #ifdef FEAT_LINEBREAK |
4905 if (!wp->w_p_lbr || !wp->w_p_list) | 4905 if (!wp->w_p_lbr || !wp->w_p_list) |
4906 #endif | 4906 #endif |
4907 /* tab amount depends on current column */ | 4907 // tab amount depends on current column |
4908 n_extra = tab_len; | 4908 n_extra = tab_len; |
4909 #ifdef FEAT_LINEBREAK | 4909 #ifdef FEAT_LINEBREAK |
4910 else | 4910 else |
4911 { | 4911 { |
4912 char_u *p; | 4912 char_u *p; |
4913 int len; | 4913 int len; |
4914 int i; | 4914 int i; |
4915 int saved_nextra = n_extra; | 4915 int saved_nextra = n_extra; |
4916 | 4916 |
4917 #ifdef FEAT_CONCEAL | 4917 #ifdef FEAT_CONCEAL |
4918 if (vcol_off > 0) | 4918 if (vcol_off > 0) |
4919 /* there are characters to conceal */ | 4919 // there are characters to conceal |
4920 tab_len += vcol_off; | 4920 tab_len += vcol_off; |
4921 /* boguscols before FIX_FOR_BOGUSCOLS macro from above | 4921 // boguscols before FIX_FOR_BOGUSCOLS macro from above |
4922 */ | |
4923 if (wp->w_p_list && lcs_tab1 && old_boguscols > 0 | 4922 if (wp->w_p_list && lcs_tab1 && old_boguscols > 0 |
4924 && n_extra > tab_len) | 4923 && n_extra > tab_len) |
4925 tab_len += n_extra - tab_len; | 4924 tab_len += n_extra - tab_len; |
4926 #endif | 4925 #endif |
4927 | 4926 |
4928 /* if n_extra > 0, it gives the number of chars, to | 4927 // if n_extra > 0, it gives the number of chars, to |
4929 * use for a tab, else we need to calculate the width | 4928 // use for a tab, else we need to calculate the width |
4930 * for a tab */ | 4929 // for a tab |
4931 len = (tab_len * mb_char2len(lcs_tab2)); | 4930 len = (tab_len * mb_char2len(lcs_tab2)); |
4932 if (n_extra > 0) | 4931 if (n_extra > 0) |
4933 len += n_extra - tab_len; | 4932 len += n_extra - tab_len; |
4934 c = lcs_tab1; | 4933 c = lcs_tab1; |
4935 p = alloc(len + 1); | 4934 p = alloc(len + 1); |
4937 p[len] = NUL; | 4936 p[len] = NUL; |
4938 vim_free(p_extra_free); | 4937 vim_free(p_extra_free); |
4939 p_extra_free = p; | 4938 p_extra_free = p; |
4940 for (i = 0; i < tab_len; i++) | 4939 for (i = 0; i < tab_len; i++) |
4941 { | 4940 { |
4941 int lcs = lcs_tab2; | |
4942 | |
4942 if (*p == NUL) | 4943 if (*p == NUL) |
4943 { | 4944 { |
4944 tab_len = i; | 4945 tab_len = i; |
4945 break; | 4946 break; |
4946 } | 4947 } |
4947 mb_char2bytes(lcs_tab2, p); | 4948 |
4948 p += mb_char2len(lcs_tab2); | 4949 // if lcs_tab3 is given, need to change the char |
4949 n_extra += mb_char2len(lcs_tab2) | 4950 // for tab |
4950 - (saved_nextra > 0 ? 1 : 0); | 4951 if (lcs_tab3 && i == tab_len - 1) |
4952 lcs = lcs_tab3; | |
4953 mb_char2bytes(lcs, p); | |
4954 p += mb_char2len(lcs); | |
4955 n_extra += mb_char2len(lcs) | |
4956 - (saved_nextra > 0 ? 1 : 0); | |
4951 } | 4957 } |
4952 p_extra = p_extra_free; | 4958 p_extra = p_extra_free; |
4953 #ifdef FEAT_CONCEAL | 4959 #ifdef FEAT_CONCEAL |
4954 /* n_extra will be increased by FIX_FOX_BOGUSCOLS | 4960 // n_extra will be increased by FIX_FOX_BOGUSCOLS |
4955 * macro below, so need to adjust for that here */ | 4961 // macro below, so need to adjust for that here |
4956 if (vcol_off > 0) | 4962 if (vcol_off > 0) |
4957 n_extra -= vcol_off; | 4963 n_extra -= vcol_off; |
4958 #endif | 4964 #endif |
4959 } | 4965 } |
4960 #endif | 4966 #endif |