comparison src/drawline.c @ 32838:eaf22d1df3c1 v9.0.1731

patch 9.0.1731: blockwise Visual highlight not working with virtual text Commit: https://github.com/vim/vim/commit/6e940d9a1d4ff122aad1b0821c784a60b507d45c Author: zeertzjq <zeertzjq@outlook.com> Date: Thu Aug 17 23:21:40 2023 +0200 patch 9.0.1731: blockwise Visual highlight not working with virtual text Problem: blockwise Visual highlight not working with virtual text Solution: Reset the correct variable at the end of virtual selection and Check for double-width char inside virtual text. closes: #12606 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
author Christian Brabandt <cb@256bit.org>
date Thu, 17 Aug 2023 23:30:04 +0200
parents 22a08166a876
children ec310fcd2d12
comparison
equal deleted inserted replaced
32837:050794aa4ef2 32838:eaf22d1df3c1
143 int extra_attr; // attributes for p_extra, should be combined 143 int extra_attr; // attributes for p_extra, should be combined
144 // with win_attr if needed 144 // with win_attr if needed
145 int n_attr_skip; // chars to skip before using extra_attr 145 int n_attr_skip; // chars to skip before using extra_attr
146 int c_extra; // extra chars, all the same 146 int c_extra; // extra chars, all the same
147 int c_final; // final char, mandatory if set 147 int c_final; // final char, mandatory if set
148 int extra_for_textprop; // wlv.n_extra set for textprop 148 int extra_for_textprop; // n_extra set for textprop
149 int start_extra_for_textprop; // extra_for_textprop was just set
149 150
150 // saved "extra" items for when draw_state becomes WL_LINE (again) 151 // saved "extra" items for when draw_state becomes WL_LINE (again)
151 int saved_n_extra; 152 int saved_n_extra;
152 char_u *saved_p_extra; 153 char_u *saved_p_extra;
153 char_u *saved_p_extra_free; 154 char_u *saved_p_extra_free;
1937 break; 1938 break;
1938 } 1939 }
1939 1940
1940 if (wlv.draw_state == WL_LINE && (area_highlighting || extra_check)) 1941 if (wlv.draw_state == WL_LINE && (area_highlighting || extra_check))
1941 { 1942 {
1942 // handle Visual or match highlighting in this line
1943 if (wlv.vcol == wlv.fromcol
1944 || (has_mbyte && wlv.vcol + 1 == wlv.fromcol
1945 && wlv.n_extra == 0
1946 && (*mb_ptr2cells)(ptr) > 1)
1947 || ((int)vcol_prev == fromcol_prev
1948 && vcol_prev < wlv.vcol // not at margin
1949 && wlv.vcol < wlv.tocol))
1950 area_attr = vi_attr; // start highlighting
1951 else if (area_attr != 0
1952 && (wlv.vcol == wlv.tocol
1953 || (noinvcur && (colnr_T)wlv.vcol == wp->w_virtcol)))
1954 area_attr = 0; // stop highlighting
1955
1956 #ifdef FEAT_PROP_POPUP 1943 #ifdef FEAT_PROP_POPUP
1957 if (text_props != NULL) 1944 if (text_props != NULL)
1958 { 1945 {
1959 int pi; 1946 int pi;
1960 int bcol = (int)(ptr - line); 1947 int bcol = (int)(ptr - line);
2129 wlv.p_extra = p; 2116 wlv.p_extra = p;
2130 wlv.c_extra = NUL; 2117 wlv.c_extra = NUL;
2131 wlv.c_final = NUL; 2118 wlv.c_final = NUL;
2132 wlv.n_extra = (int)STRLEN(p); 2119 wlv.n_extra = (int)STRLEN(p);
2133 wlv.extra_for_textprop = TRUE; 2120 wlv.extra_for_textprop = TRUE;
2121 wlv.start_extra_for_textprop = TRUE;
2134 wlv.extra_attr = hl_combine_attr(wlv.win_attr, 2122 wlv.extra_attr = hl_combine_attr(wlv.win_attr,
2135 used_attr); 2123 used_attr);
2136 n_attr = mb_charlen(p); 2124 n_attr = mb_charlen(p);
2137 // restore search_attr and area_attr when n_extra
2138 // is down to zero
2139 saved_search_attr = search_attr;
2140 saved_area_attr = area_attr;
2141 search_attr = 0;
2142 area_attr = 0;
2143 text_prop_attr = 0; 2125 text_prop_attr = 0;
2144 text_prop_attr_comb = 0; 2126 text_prop_attr_comb = 0;
2145 if (*ptr == NUL) 2127 if (*ptr == NUL)
2146 // don't combine char attr after EOL 2128 // don't combine char attr after EOL
2147 text_prop_flags &= ~PT_FLAG_COMBINE; 2129 text_prop_flags &= ~PT_FLAG_COMBINE;
2256 // follows after it, we may need to flush the line after 2238 // follows after it, we may need to flush the line after
2257 // displaying that character. 2239 // displaying that character.
2258 // Or when not wrapping and at the rightmost column. 2240 // Or when not wrapping and at the rightmost column.
2259 text_prop_follows = TRUE; 2241 text_prop_follows = TRUE;
2260 } 2242 }
2261 #endif 2243
2244 if (wlv.start_extra_for_textprop)
2245 {
2246 wlv.start_extra_for_textprop = FALSE;
2247 // restore search_attr and area_attr when n_extra
2248 // is down to zero
2249 saved_search_attr = search_attr;
2250 saved_area_attr = area_attr;
2251 search_attr = 0;
2252 area_attr = 0;
2253 }
2254 #endif
2255
2256 int *area_attr_p =
2257 #ifdef FEAT_PROP_POPUP
2258 wlv.extra_for_textprop ? &saved_area_attr :
2259 #endif
2260 &area_attr;
2261
2262 // handle Visual or match highlighting in this line
2263 if (wlv.vcol == wlv.fromcol
2264 || (has_mbyte && wlv.vcol + 1 == wlv.fromcol
2265 && ((wlv.n_extra == 0 && (*mb_ptr2cells)(ptr) > 1)
2266 || (wlv.n_extra > 0 && wlv.p_extra != NULL
2267 && (*mb_ptr2cells)(wlv.p_extra) > 1)))
2268 || ((int)vcol_prev == fromcol_prev
2269 && vcol_prev < wlv.vcol // not at margin
2270 && wlv.vcol < wlv.tocol))
2271 *area_attr_p = vi_attr; // start highlighting
2272 else if (*area_attr_p != 0
2273 && (wlv.vcol == wlv.tocol
2274 || (noinvcur && (colnr_T)wlv.vcol == wp->w_virtcol)))
2275 *area_attr_p = 0; // stop highlighting
2262 2276
2263 #ifdef FEAT_SEARCH_EXTRA 2277 #ifdef FEAT_SEARCH_EXTRA
2264 if (wlv.n_extra == 0) 2278 if (wlv.n_extra == 0)
2265 { 2279 {
2266 // Check for start/end of 'hlsearch' and other matches. 2280 // Check for start/end of 'hlsearch' and other matches.