Mercurial > vim
comparison src/drawline.c @ 32824:22a08166a876 v9.0.1725
patch 9.0.1725: cursor pos wrong after concealed text with 'virtualedit'
Commit: https://github.com/vim/vim/commit/e500ae8e29ad921378085f5d70ee5c0c537be1ba
Author: zeertzjq <zeertzjq@outlook.com>
Date: Thu Aug 17 22:35:26 2023 +0200
patch 9.0.1725: cursor pos wrong after concealed text with 'virtualedit'
Problem: Wrong cursor position when clicking after concealed text
with 'virtualedit'.
Solution: Store virtual columns in ScreenCols[] instead of text
columns, and always use coladvance() when clicking.
This also fixes incorrect curswant when clicking on a TAB, so now
Test_normal_click_on_ctrl_char() asserts the same results as the ones
before patch 9.0.0048.
closes: #12808
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 22:45:04 +0200 |
parents | 1be7af7425f6 |
children | eaf22d1df3c1 |
comparison
equal
deleted
inserted
replaced
32823:d18b744d834b | 32824:22a08166a876 |
---|---|
1827 } | 1827 } |
1828 #endif | 1828 #endif |
1829 | 1829 |
1830 win_line_start(wp, &wlv, FALSE); | 1830 win_line_start(wp, &wlv, FALSE); |
1831 | 1831 |
1832 char_u *prev_ptr = ptr; | |
1833 // Repeat for the whole displayed line. | 1832 // Repeat for the whole displayed line. |
1834 for (;;) | 1833 for (;;) |
1835 { | 1834 { |
1836 #if defined(FEAT_CONCEAL) || defined(FEAT_SEARCH_EXTRA) | 1835 #if defined(FEAT_CONCEAL) || defined(FEAT_SEARCH_EXTRA) |
1837 int has_match_conc = 0; // match wants to conceal | 1836 int has_match_conc = 0; // match wants to conceal |
2259 // Or when not wrapping and at the rightmost column. | 2258 // Or when not wrapping and at the rightmost column. |
2260 text_prop_follows = TRUE; | 2259 text_prop_follows = TRUE; |
2261 } | 2260 } |
2262 #endif | 2261 #endif |
2263 | 2262 |
2263 #ifdef FEAT_SEARCH_EXTRA | |
2264 if (wlv.n_extra == 0) | 2264 if (wlv.n_extra == 0) |
2265 { | 2265 { |
2266 #ifdef FEAT_SEARCH_EXTRA | |
2267 // Check for start/end of 'hlsearch' and other matches. | 2266 // Check for start/end of 'hlsearch' and other matches. |
2268 // After end, check for start/end of next match. | 2267 // After end, check for start/end of next match. |
2269 // When another match, have to check for start again. | 2268 // When another match, have to check for start again. |
2270 v = (long)(ptr - line); | 2269 v = (long)(ptr - line); |
2271 search_attr = update_search_hl(wp, lnum, (colnr_T)v, &line, | 2270 search_attr = update_search_hl(wp, lnum, (colnr_T)v, &line, |
2276 | 2275 |
2277 // Do not allow a conceal over EOL otherwise EOL will be missed | 2276 // Do not allow a conceal over EOL otherwise EOL will be missed |
2278 // and bad things happen. | 2277 // and bad things happen. |
2279 if (*ptr == NUL) | 2278 if (*ptr == NUL) |
2280 has_match_conc = 0; | 2279 has_match_conc = 0; |
2281 #endif | 2280 } |
2282 | 2281 #endif |
2283 prev_ptr = ptr; | |
2284 } | |
2285 | 2282 |
2286 #ifdef FEAT_DIFF | 2283 #ifdef FEAT_DIFF |
2287 if (wlv.diff_hlf != (hlf_T)0) | 2284 if (wlv.diff_hlf != (hlf_T)0) |
2288 { | 2285 { |
2289 // When there is extra text (e.g. virtual text) it gets the | 2286 // When there is extra text (e.g. virtual text) it gets the |
2354 | 2351 |
2355 // Need to get the line again, a multi-line regexp may | 2352 // Need to get the line again, a multi-line regexp may |
2356 // have made it invalid. | 2353 // have made it invalid. |
2357 line = ml_get_buf(wp->w_buffer, lnum, FALSE); | 2354 line = ml_get_buf(wp->w_buffer, lnum, FALSE); |
2358 ptr = line + v; | 2355 ptr = line + v; |
2359 prev_ptr = ptr; | |
2360 # ifdef FEAT_CONCEAL | 2356 # ifdef FEAT_CONCEAL |
2361 // no concealing past the end of the line, it interferes | 2357 // no concealing past the end of the line, it interferes |
2362 // with line highlighting | 2358 // with line highlighting |
2363 if (*ptr == NUL) | 2359 if (*ptr == NUL) |
2364 syntax_flags = 0; | 2360 syntax_flags = 0; |
2565 else | 2561 else |
2566 { | 2562 { |
2567 #ifdef FEAT_LINEBREAK | 2563 #ifdef FEAT_LINEBREAK |
2568 int c0; | 2564 int c0; |
2569 #endif | 2565 #endif |
2570 prev_ptr = ptr; | 2566 #ifdef FEAT_SPELL |
2567 char_u *prev_ptr = ptr; | |
2568 #endif | |
2571 | 2569 |
2572 // Get a character from the line itself. | 2570 // Get a character from the line itself. |
2573 c = *ptr; | 2571 c = *ptr; |
2574 #ifdef FEAT_LINEBREAK | 2572 #ifdef FEAT_LINEBREAK |
2575 c0 = *ptr; | 2573 c0 = *ptr; |
3807 multi_attr = 0; | 3805 multi_attr = 0; |
3808 } | 3806 } |
3809 else | 3807 else |
3810 ScreenAttrs[wlv.off] = wlv.char_attr; | 3808 ScreenAttrs[wlv.off] = wlv.char_attr; |
3811 | 3809 |
3812 ScreenCols[wlv.off] = (colnr_T)(prev_ptr - line); | 3810 ScreenCols[wlv.off] = wlv.vcol; |
3813 | 3811 |
3814 if (has_mbyte && (*mb_char2cells)(mb_c) > 1) | 3812 if (has_mbyte && (*mb_char2cells)(mb_c) > 1) |
3815 { | 3813 { |
3816 // Need to fill two screen columns. | 3814 // Need to fill two screen columns. |
3817 ++wlv.off; | 3815 ++wlv.off; |
3831 // When "wlv.tocol" is halfway a character, set it to the end | 3829 // When "wlv.tocol" is halfway a character, set it to the end |
3832 // of the character, otherwise highlighting won't stop. | 3830 // of the character, otherwise highlighting won't stop. |
3833 if (wlv.tocol == wlv.vcol) | 3831 if (wlv.tocol == wlv.vcol) |
3834 ++wlv.tocol; | 3832 ++wlv.tocol; |
3835 | 3833 |
3836 ScreenCols[wlv.off] = (colnr_T)(prev_ptr - line); | 3834 ScreenCols[wlv.off] = wlv.vcol; |
3837 | 3835 |
3838 #ifdef FEAT_RIGHTLEFT | 3836 #ifdef FEAT_RIGHTLEFT |
3839 if (wp->w_p_rl) | 3837 if (wp->w_p_rl) |
3840 { | 3838 { |
3841 // now it's time to backup one cell | 3839 // now it's time to backup one cell |