patch 9.1.0186: cursor pos wrong on mouse click after eol with 'rl', 've' and conceal
Problem: Wrong cursor position when clicking after end of line with
'rightleft', 'virtualedit' and conceal.
Solution: Set values in ScreenCols[] also with SLF_RIGHTLEFT. Also fix
off-by-one cursor position with 'colorcolumn' (zeertzjq).
closes: #14218
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/screen.c b/src/screen.c
index 08b1c01..71ddbca 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -18,8 +18,7 @@
* displayed (excluding text written by external commands).
* ScreenAttrs[off] Contains the associated attributes.
* ScreenCols[off] Contains the virtual columns in the line. -1 means not
- * available or before buffer text, MAXCOL means after the
- * end of the line.
+ * available or before buffer text.
*
* LineOffset[row] Contains the offset into ScreenLines*[], ScreenAttrs[]
* and ScreenCols[] for each line.
@@ -509,6 +508,8 @@
// Clear rest first, because it's left of the text.
if (clear_width > 0)
{
+ int clear_start = col;
+
while (col <= endcol && ScreenLines[off_to] == ' '
&& ScreenAttrs[off_to] == 0
&& (!enc_utf8 || ScreenLinesUC[off_to] == 0))
@@ -519,6 +520,10 @@
if (col <= endcol)
screen_fill(row, row + 1, col + coloff,
endcol + coloff + 1, ' ', ' ', 0);
+
+ for (int i = endcol; i >= clear_start; i--)
+ ScreenCols[off_to + (i - col)] =
+ (flags & SLF_INC_VCOL) ? ++last_vcol : last_vcol;
}
col = endcol + 1;
off_to = LineOffset[row] + col + coloff;