comparison src/charset.c @ 29655:53e434838a85 v9.0.0168

patch 9.0.0168: cursor positioned wrong with two virtual text properties Commit: https://github.com/vim/vim/commit/25463610dfc7a4984f70b030463fb98b09772ad9 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Aug 8 11:07:47 2022 +0100 patch 9.0.0168: cursor positioned wrong with two virtual text properties Problem: Cursor positioned wrong with two virtual text properties close together. (Ben Jackson) Solution: Add the original size, not the computed one. (closes #10864)
author Bram Moolenaar <Bram@vim.org>
date Mon, 08 Aug 2022 12:15:06 +0200
parents e80174903fdf
children b4fea827c20a
comparison
equal deleted inserted replaced
29654:bba83ec5cf86 29655:53e434838a85
1128 size = win_chartabsize(wp, s, vcol); 1128 size = win_chartabsize(wp, s, vcol);
1129 1129
1130 # ifdef FEAT_PROP_POPUP 1130 # ifdef FEAT_PROP_POPUP
1131 if (cts->cts_has_prop_with_text && *line != NUL) 1131 if (cts->cts_has_prop_with_text && *line != NUL)
1132 { 1132 {
1133 int normal_size = size;
1133 int i; 1134 int i;
1134 int col = (int)(s - line); 1135 int col = (int)(s - line);
1135 garray_T *gap = &wp->w_buffer->b_textprop_text; 1136 garray_T *gap = &wp->w_buffer->b_textprop_text;
1136 1137
1137 for (i = 0; i < cts->cts_text_prop_count; ++i) 1138 for (i = 0; i < cts->cts_text_prop_count; ++i)
1139 textprop_T *tp = cts->cts_text_props + i; 1140 textprop_T *tp = cts->cts_text_props + i;
1140 1141
1141 // Watch out for the text being deleted. "cts_text_props" is a 1142 // Watch out for the text being deleted. "cts_text_props" is a
1142 // copy, the text prop may actually have been removed from the line. 1143 // copy, the text prop may actually have been removed from the line.
1143 if (tp->tp_id < 0 1144 if (tp->tp_id < 0
1144 && ((tp->tp_col - 1 >= col && tp->tp_col - 1 < col + size) 1145 && ((tp->tp_col - 1 >= col
1146 && tp->tp_col - 1 < col + normal_size)
1145 || (tp->tp_col == MAXCOL && (s[0] == NUL || s[1] == NUL) 1147 || (tp->tp_col == MAXCOL && (s[0] == NUL || s[1] == NUL)
1146 && cts->cts_with_trailing)) 1148 && cts->cts_with_trailing))
1147 && -tp->tp_id - 1 < gap->ga_len) 1149 && -tp->tp_id - 1 < gap->ga_len)
1148 { 1150 {
1149 char_u *p = ((char_u **)gap->ga_data)[-tp->tp_id - 1]; 1151 char_u *p = ((char_u **)gap->ga_data)[-tp->tp_id - 1];
1150 1152
1151 if (p != NULL) 1153 if (p != NULL)
1152 { 1154 {
1153 int cells = vim_strsize(p); 1155 int cells = vim_strsize(p);
1154 1156
1155 added = wp->w_width - (vcol + size) % wp->w_width;
1156 if (tp->tp_col == MAXCOL) 1157 if (tp->tp_col == MAXCOL)
1157 { 1158 {
1158 int below = (tp->tp_flags & TP_FLAG_ALIGN_BELOW); 1159 int below = (tp->tp_flags & TP_FLAG_ALIGN_BELOW);
1159 int wrap = (tp->tp_flags & TP_FLAG_WRAP); 1160 int wrap = (tp->tp_flags & TP_FLAG_WRAP);
1160 int len = (int)STRLEN(p); 1161 int len = (int)STRLEN(p);
1161 int n_used = len; 1162 int n_used = len;
1162 1163
1163 // Keep in sync with where textprop_size_after_trunc() 1164 // Keep in sync with where textprop_size_after_trunc()
1164 // is called in win_line(). 1165 // is called in win_line().
1165 if (!wrap) 1166 if (!wrap)
1167 {
1168 added = wp->w_width - (vcol + size) % wp->w_width;
1166 cells = textprop_size_after_trunc(wp, 1169 cells = textprop_size_after_trunc(wp,
1167 below, added, p, &n_used); 1170 below, added, p, &n_used);
1171 }
1168 // right-aligned does not really matter here, same as 1172 // right-aligned does not really matter here, same as
1169 // "after" 1173 // "after"
1170 if (below) 1174 if (below)
1171 cells += wp->w_width - (vcol + size) % wp->w_width; 1175 cells += wp->w_width - (vcol + size) % wp->w_width;
1172 #ifdef FEAT_LINEBREAK 1176 #ifdef FEAT_LINEBREAK