comparison src/charset.c @ 18574:8b0114ffde2b v8.1.2281

patch 8.1.2281: 'showbreak' cannot be set for one window Commit: https://github.com/vim/vim/commit/ee85702c10495041791f728e977b86005c4496e8 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Nov 9 23:26:40 2019 +0100 patch 8.1.2281: 'showbreak' cannot be set for one window Problem: 'showbreak' cannot be set for one window. Solution: Make 'showbreak' global-local.
author Bram Moolenaar <Bram@vim.org>
date Sat, 09 Nov 2019 23:30:03 +0100
parents 1c7a91cf2356
children c469e1930456
comparison
equal deleted inserted replaced
18573:f18a4ae518f1 18574:8b0114ffde2b
934 char_u *line UNUSED, /* start of the line */ 934 char_u *line UNUSED, /* start of the line */
935 unsigned char *s, 935 unsigned char *s,
936 colnr_T col) 936 colnr_T col)
937 { 937 {
938 #ifdef FEAT_LINEBREAK 938 #ifdef FEAT_LINEBREAK
939 if (!curwin->w_p_lbr && *p_sbr == NUL && !curwin->w_p_bri) 939 if (!curwin->w_p_lbr && *get_showbreak_value(curwin) == NUL
940 && !curwin->w_p_bri)
940 { 941 {
941 #endif 942 #endif
942 if (curwin->w_p_wrap) 943 if (curwin->w_p_wrap)
943 return win_nolbr_chartabsize(curwin, s, col, NULL); 944 return win_nolbr_chartabsize(curwin, s, col, NULL);
944 RET_WIN_BUF_CHARTABSIZE(curwin, curbuf, s, col) 945 RET_WIN_BUF_CHARTABSIZE(curwin, curbuf, s, col)
989 int mb_added = 0; 990 int mb_added = 0;
990 int numberextra; 991 int numberextra;
991 char_u *ps; 992 char_u *ps;
992 int tab_corr = (*s == TAB); 993 int tab_corr = (*s == TAB);
993 int n; 994 int n;
995 char_u *sbr;
994 996
995 /* 997 /*
996 * No 'linebreak', 'showbreak' and 'breakindent': return quickly. 998 * No 'linebreak', 'showbreak' and 'breakindent': return quickly.
997 */ 999 */
998 if (!wp->w_p_lbr && !wp->w_p_bri && *p_sbr == NUL) 1000 if (!wp->w_p_lbr && !wp->w_p_bri && *get_showbreak_value(wp) == NUL)
999 #endif 1001 #endif
1000 { 1002 {
1001 if (wp->w_p_wrap) 1003 if (wp->w_p_wrap)
1002 return win_nolbr_chartabsize(wp, s, col, headp); 1004 return win_nolbr_chartabsize(wp, s, col, headp);
1003 RET_WIN_BUF_CHARTABSIZE(wp, wp->w_buffer, s, col) 1005 RET_WIN_BUF_CHARTABSIZE(wp, wp->w_buffer, s, col)
1067 * May have to add something for 'breakindent' and/or 'showbreak' 1069 * May have to add something for 'breakindent' and/or 'showbreak'
1068 * string at start of line. 1070 * string at start of line.
1069 * Set *headp to the size of what we add. 1071 * Set *headp to the size of what we add.
1070 */ 1072 */
1071 added = 0; 1073 added = 0;
1072 if ((*p_sbr != NUL || wp->w_p_bri) && wp->w_p_wrap && col != 0) 1074 sbr = get_showbreak_value(wp);
1075 if ((*sbr != NUL || wp->w_p_bri) && wp->w_p_wrap && col != 0)
1073 { 1076 {
1074 colnr_T sbrlen = 0; 1077 colnr_T sbrlen = 0;
1075 int numberwidth = win_col_off(wp); 1078 int numberwidth = win_col_off(wp);
1076 1079
1077 numberextra = numberwidth; 1080 numberextra = numberwidth;
1080 { 1083 {
1081 col -= wp->w_width; 1084 col -= wp->w_width;
1082 numberextra = wp->w_width - (numberextra - win_col_off2(wp)); 1085 numberextra = wp->w_width - (numberextra - win_col_off2(wp));
1083 if (col >= numberextra && numberextra > 0) 1086 if (col >= numberextra && numberextra > 0)
1084 col %= numberextra; 1087 col %= numberextra;
1085 if (*p_sbr != NUL) 1088 if (*sbr != NUL)
1086 { 1089 {
1087 sbrlen = (colnr_T)MB_CHARLEN(p_sbr); 1090 sbrlen = (colnr_T)MB_CHARLEN(sbr);
1088 if (col >= sbrlen) 1091 if (col >= sbrlen)
1089 col -= sbrlen; 1092 col -= sbrlen;
1090 } 1093 }
1091 if (col >= numberextra && numberextra > 0) 1094 if (col >= numberextra && numberextra > 0)
1092 col = col % numberextra; 1095 col = col % numberextra;
1096 numberwidth -= win_col_off2(wp); 1099 numberwidth -= win_col_off2(wp);
1097 } 1100 }
1098 if (col == 0 || col + size + sbrlen > (colnr_T)wp->w_width) 1101 if (col == 0 || col + size + sbrlen > (colnr_T)wp->w_width)
1099 { 1102 {
1100 added = 0; 1103 added = 0;
1101 if (*p_sbr != NUL) 1104 if (*sbr != NUL)
1102 { 1105 {
1103 if (size + sbrlen + numberwidth > (colnr_T)wp->w_width) 1106 if (size + sbrlen + numberwidth > (colnr_T)wp->w_width)
1104 { 1107 {
1105 // calculate effective window width 1108 // calculate effective window width
1106 int width = (colnr_T)wp->w_width - sbrlen - numberwidth; 1109 int width = (colnr_T)wp->w_width - sbrlen - numberwidth;
1107 int prev_width = col 1110 int prev_width = col
1108 ? ((colnr_T)wp->w_width - (sbrlen + col)) : 0; 1111 ? ((colnr_T)wp->w_width - (sbrlen + col)) : 0;
1109 1112
1110 if (width <= 0) 1113 if (width <= 0)
1111 width = (colnr_T)1; 1114 width = (colnr_T)1;
1112 added += ((size - prev_width) / width) * vim_strsize(p_sbr); 1115 added += ((size - prev_width) / width) * vim_strsize(sbr);
1113 if ((size - prev_width) % width) 1116 if ((size - prev_width) % width)
1114 // wrapped, add another length of 'sbr' 1117 // wrapped, add another length of 'sbr'
1115 added += vim_strsize(p_sbr); 1118 added += vim_strsize(sbr);
1116 } 1119 }
1117 else 1120 else
1118 added += vim_strsize(p_sbr); 1121 added += vim_strsize(sbr);
1119 } 1122 }
1120 if (wp->w_p_bri) 1123 if (wp->w_p_bri)
1121 added += get_breakindent_win(wp, line); 1124 added += get_breakindent_win(wp, line);
1122 1125
1123 size += added; 1126 size += added;
1240 * use a simple loop. 1243 * use a simple loop.
1241 * Also use this when 'list' is set but tabs take their normal size. 1244 * Also use this when 'list' is set but tabs take their normal size.
1242 */ 1245 */
1243 if ((!wp->w_p_list || lcs_tab1 != NUL) 1246 if ((!wp->w_p_list || lcs_tab1 != NUL)
1244 #ifdef FEAT_LINEBREAK 1247 #ifdef FEAT_LINEBREAK
1245 && !wp->w_p_lbr && *p_sbr == NUL && !wp->w_p_bri 1248 && !wp->w_p_lbr && *get_showbreak_value(wp) == NUL && !wp->w_p_bri
1246 #endif 1249 #endif
1247 ) 1250 )
1248 { 1251 {
1249 for (;;) 1252 for (;;)
1250 { 1253 {