comparison src/drawline.c @ 34571:fdd232ab72ea v9.1.0184

patch 9.1.0184: Cursor pos wrong when clicking with conceal and wrap Commit: https://github.com/vim/vim/commit/d0c1b7723f7e73763597af2f97a53d94ab7ed020 Author: zeertzjq <zeertzjq@outlook.com> Date: Sat Mar 16 15:03:33 2024 +0100 patch 9.1.0184: Cursor pos wrong when clicking with conceal and wrap Problem: Cursor position wrong when clicking with conceal and wrap. Solution: Use the virtual column of the last char for ScreenCols[] in boguscols. Remove use of MAXCOL in ScreenCols[]. Rename third argument of wlv_screen_line() to "clear_end" as that's clearer what it does (zeertzjq). related: 14192 closes: #14200 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sat, 16 Mar 2024 15:15:04 +0100
parents ef55fe2ac8be
children 74baeec0f24f
comparison
equal deleted inserted replaced
34570:68553f944407 34571:fdd232ab72ea
830 830
831 /* 831 /*
832 * Call screen_line() using values from "wlv". 832 * Call screen_line() using values from "wlv".
833 * Also takes care of putting "<<<" on the first line for 'smoothscroll' 833 * Also takes care of putting "<<<" on the first line for 'smoothscroll'
834 * when 'showbreak' is not set. 834 * when 'showbreak' is not set.
835 * When "clear_end" is TRUE clear until the end of the screen line.
835 */ 836 */
836 static void 837 static void
837 wlv_screen_line(win_T *wp, winlinevars_T *wlv, int negative_width) 838 wlv_screen_line(win_T *wp, winlinevars_T *wlv, int clear_end)
838 { 839 {
839 if (wlv->row == 0 && wp->w_skipcol > 0 840 if (wlv->row == 0 && wp->w_skipcol > 0
840 #if defined(FEAT_LINEBREAK) 841 #if defined(FEAT_LINEBREAK)
841 // do not overwrite the 'showbreak' text with "<<<" 842 // do not overwrite the 'showbreak' text with "<<<"
842 && *get_showbreak_value(wp) == NUL 843 && *get_showbreak_value(wp) == NUL
870 ++off; 871 ++off;
871 } 872 }
872 } 873 }
873 874
874 screen_line(wp, wlv->screen_row, wp->w_wincol, wlv->col, 875 screen_line(wp, wlv->screen_row, wp->w_wincol, wlv->col,
875 negative_width ? -wp->w_width : wp->w_width, 876 clear_end ? wp->w_width : -wp->w_width,
876 wlv->screen_line_flags); 877 wlv->vcol - 1, wlv->screen_line_flags);
877 } 878 }
878 879
879 /* 880 /*
880 * Called when finished with the line: draw the screen line and handle any 881 * Called when finished with the line: draw the screen line and handle any
881 * highlighting until the right of the window. 882 * highlighting until the right of the window.
937 while (wlv->col < wp->w_width) 938 while (wlv->col < wp->w_width)
938 { 939 {
939 ScreenLines[wlv->off] = ' '; 940 ScreenLines[wlv->off] = ' ';
940 if (enc_utf8) 941 if (enc_utf8)
941 ScreenLinesUC[wlv->off] = 0; 942 ScreenLinesUC[wlv->off] = 0;
942 ScreenCols[wlv->off] = MAXCOL; 943 ScreenCols[wlv->off] = wlv->vcol;
943 ++wlv->col; 944 ++wlv->col;
944 if (wlv->draw_color_col) 945 if (wlv->draw_color_col)
945 wlv->draw_color_col = advance_color_col( 946 wlv->draw_color_col = advance_color_col(
946 VCOL_HLC, &wlv->color_cols); 947 VCOL_HLC, &wlv->color_cols);
947 948
967 ++wlv->vcol; 968 ++wlv->vcol;
968 } 969 }
969 } 970 }
970 #endif 971 #endif
971 972
972 wlv_screen_line(wp, wlv, FALSE); 973 // Set increasing virtual columns in ScreenCols[] to set correct curswant
974 // (or "coladd" for 'virtualedit') when clicking after end of line.
975 wlv->screen_line_flags |= SLF_INC_VCOL;
976 wlv_screen_line(wp, wlv, TRUE);
977 wlv->screen_line_flags &= ~SLF_INC_VCOL;
973 ++wlv->row; 978 ++wlv->row;
974 ++wlv->screen_row; 979 ++wlv->screen_row;
975 } 980 }
976 #undef VCOL_HLC 981 #undef VCOL_HLC
977 982
1926 1931
1927 // When only displaying the (relative) line number and that's done, 1932 // When only displaying the (relative) line number and that's done,
1928 // stop here. 1933 // stop here.
1929 if (number_only > 0 && wlv.draw_state == WL_NR && wlv.n_extra == 0) 1934 if (number_only > 0 && wlv.draw_state == WL_NR && wlv.n_extra == 0)
1930 { 1935 {
1931 wlv_screen_line(wp, &wlv, TRUE); 1936 wlv_screen_line(wp, &wlv, FALSE);
1932 // Need to update more screen lines if: 1937 // Need to update more screen lines if:
1933 // - LineNrAbove or LineNrBelow is used, or 1938 // - LineNrAbove or LineNrBelow is used, or
1934 // - still drawing filler lines. 1939 // - still drawing filler lines.
1935 if ((wlv.row + 1 - wlv.startrow < number_only 1940 if ((wlv.row + 1 - wlv.startrow < number_only
1936 && (HL_ATTR(HLF_LNA) != 0 || HL_ATTR(HLF_LNB) != 0)) 1941 && (HL_ATTR(HLF_LNA) != 0 || HL_ATTR(HLF_LNB) != 0))
1985 // When still displaying '$' of change command, stop at cursor. 1990 // When still displaying '$' of change command, stop at cursor.
1986 if (dollar_vcol >= 0 && wp == curwin 1991 if (dollar_vcol >= 0 && wp == curwin
1987 && lnum == wp->w_cursor.lnum 1992 && lnum == wp->w_cursor.lnum
1988 && wlv.vcol >= (long)wp->w_virtcol) 1993 && wlv.vcol >= (long)wp->w_virtcol)
1989 { 1994 {
1990 wlv_screen_line(wp, &wlv, TRUE); 1995 wlv_screen_line(wp, &wlv, FALSE);
1991 // Pretend we have finished updating the window. Except when 1996 // Pretend we have finished updating the window. Except when
1992 // 'cursorcolumn' is set. 1997 // 'cursorcolumn' is set.
1993 #ifdef FEAT_SYN_HL 1998 #ifdef FEAT_SYN_HL
1994 if (wp->w_p_cuc) 1999 if (wp->w_p_cuc)
1995 wlv.row = wp->w_cline_row + wp->w_cline_height; 2000 wlv.row = wp->w_cline_row + wp->w_cline_height;
3762 get_search_match_hl(wp, &screen_search_hl, 3767 get_search_match_hl(wp, &screen_search_hl,
3763 (long)(ptr - line), &wlv.char_attr); 3768 (long)(ptr - line), &wlv.char_attr);
3764 } 3769 }
3765 #endif 3770 #endif
3766 ScreenAttrs[wlv.off] = wlv.char_attr; 3771 ScreenAttrs[wlv.off] = wlv.char_attr;
3767 ScreenCols[wlv.off] = MAXCOL; 3772 ScreenCols[wlv.off] = wlv.vcol;
3768 #ifdef FEAT_RIGHTLEFT 3773 #ifdef FEAT_RIGHTLEFT
3769 if (wp->w_p_rl) 3774 if (wp->w_p_rl)
3770 { 3775 {
3771 --wlv.col; 3776 --wlv.col;
3772 --wlv.off; 3777 --wlv.off;
4165 { 4170 {
4166 ScreenLines[wlv.off] = ' '; 4171 ScreenLines[wlv.off] = ' ';
4167 if (enc_utf8) 4172 if (enc_utf8)
4168 ScreenLinesUC[wlv.off] = 0; 4173 ScreenLinesUC[wlv.off] = 0;
4169 ScreenAttrs[wlv.off] = attr; 4174 ScreenAttrs[wlv.off] = attr;
4170 ScreenCols[wlv.off] = MAXCOL; // TODO: this is wrong 4175 ScreenCols[wlv.off] = wlv.vcol - 1;
4171 # ifdef FEAT_RIGHTLEFT 4176 # ifdef FEAT_RIGHTLEFT
4172 if (wp->w_p_rl) 4177 if (wp->w_p_rl)
4173 { 4178 {
4174 wlv.off--; 4179 wlv.off--;
4175 wlv.col--; 4180 wlv.col--;
4182 wlv.col++; 4187 wlv.col++;
4183 wlv.boguscols--; 4188 wlv.boguscols--;
4184 } 4189 }
4185 } 4190 }
4186 } 4191 }
4187 wlv_screen_line(wp, &wlv, FALSE); 4192 wlv_screen_line(wp, &wlv, TRUE);
4188 wlv.col += wlv.boguscols; 4193 wlv.col += wlv.boguscols;
4189 wlv.boguscols = 0; 4194 wlv.boguscols = 0;
4190 wlv.vcol_off_co = 0; 4195 wlv.vcol_off_co = 0;
4191 #else 4196 #else
4192 wlv_screen_line(wp, &wlv, FALSE); 4197 wlv_screen_line(wp, &wlv, TRUE);
4193 #endif 4198 #endif
4194 ++wlv.row; 4199 ++wlv.row;
4195 ++wlv.screen_row; 4200 ++wlv.screen_row;
4196 4201
4197 // When not wrapping and finished diff lines, break here. 4202 // When not wrapping and finished diff lines, break here.