summaryrefslogtreecommitdiffstats
path: root/src/drawline.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-07-09 04:56:24 +0100
committerBram Moolenaar <Bram@vim.org>2022-07-09 04:56:24 +0100
commitb90818867c089d4987f1a48ee3666674826d6f4b (patch)
treee56211c21510cf77f5843aab008901ed410b7df6 /src/drawline.c
parentfee0c4aa99eb0a7a801dade758ce5e04b48c15d1 (diff)
patch 9.0.0048: cursor in wrong column with mouse click after concealed textv9.0.0048
Problem: Cursor in wrong column with mouse click after concealed text. Solution: Store the text column when drawing text.
Diffstat (limited to 'src/drawline.c')
-rw-r--r--src/drawline.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/drawline.c b/src/drawline.c
index 789893b0b2..e91ef291dc 100644
--- a/src/drawline.c
+++ b/src/drawline.c
@@ -779,7 +779,7 @@ win_line(
trailcol = (colnr_T)STRLEN(ptr);
while (trailcol > (colnr_T)0 && VIM_ISWHITE(ptr[trailcol - 1]))
--trailcol;
- trailcol += (colnr_T) (ptr - line);
+ trailcol += (colnr_T)(ptr - line);
}
// find end of leading whitespace
if (wp->w_lcs_chars.lead || wp->w_lcs_chars.leadmultispace != NULL)
@@ -792,7 +792,7 @@ win_line(
leadcol = (colnr_T)0;
else
// keep track of the first column not filled with spaces
- leadcol += (colnr_T) (ptr - line) + 1;
+ leadcol += (colnr_T)(ptr - line) + 1;
}
}
@@ -1027,12 +1027,14 @@ win_line(
// Repeat for the whole displayed line.
for (;;)
{
+ char_u *prev_ptr = ptr;
#if defined(FEAT_CONCEAL) || defined(FEAT_SEARCH_EXTRA)
- int has_match_conc = 0; // match wants to conceal
+ int has_match_conc = 0; // match wants to conceal
#endif
#ifdef FEAT_CONCEAL
- int did_decrement_ptr = FALSE;
+ int did_decrement_ptr = FALSE;
#endif
+
// Skip this quickly when working on the text.
if (draw_state != WL_LINE)
{
@@ -1392,6 +1394,7 @@ win_line(
&match_conc, did_line_attr, lcs_eol_one,
&on_last_col);
ptr = line + v; // "line" may have been changed
+ prev_ptr = ptr;
// Do not allow a conceal over EOL otherwise EOL will be missed
// and bad things happen.
@@ -1553,6 +1556,7 @@ win_line(
// have made it invalid.
line = ml_get_buf(wp->w_buffer, lnum, FALSE);
ptr = line + v;
+ prev_ptr = ptr;
# ifdef FEAT_CONCEAL
// no concealing past the end of the line, it interferes
// with line highlighting
@@ -1733,9 +1737,10 @@ win_line(
else
{
#ifdef FEAT_LINEBREAK
- int c0;
+ int c0;
#endif
VIM_CLEAR(p_extra_free);
+ prev_ptr = ptr;
// Get a character from the line itself.
c = *ptr;
@@ -1942,17 +1947,12 @@ win_line(
# endif
can_spell))
{
- char_u *prev_ptr, *p;
+ char_u *p;
int len;
hlf_T spell_hlf = HLF_COUNT;
if (has_mbyte)
- {
- prev_ptr = ptr - mb_l;
v -= mb_l - 1;
- }
- else
- prev_ptr = ptr - 1;
// Use nextline[] if possible, it has the start of the
// next line concatenated.
@@ -2771,6 +2771,7 @@ win_line(
}
#endif
ScreenAttrs[off] = char_attr;
+ ScreenCols[off] = MAXCOL;
#ifdef FEAT_RIGHTLEFT
if (wp->w_p_rl)
{
@@ -2839,6 +2840,7 @@ win_line(
ScreenLines[off] = ' ';
if (enc_utf8)
ScreenLinesUC[off] = 0;
+ ScreenCols[off] = MAXCOL;
++col;
if (draw_color_col)
draw_color_col = advance_color_col(VCOL_HLC,
@@ -2992,6 +2994,8 @@ win_line(
else
ScreenAttrs[off] = char_attr;
+ ScreenCols[off] = (colnr_T)(prev_ptr - line);
+
if (has_mbyte && (*mb_char2cells)(mb_c) > 1)
{
// Need to fill two screen columns.
@@ -3013,6 +3017,9 @@ win_line(
// the character, otherwise highlighting won't stop.
if (tocol == vcol)
++tocol;
+
+ ScreenCols[off] = (colnr_T)(prev_ptr - line);
+
#ifdef FEAT_RIGHTLEFT
if (wp->w_p_rl)
{