summaryrefslogtreecommitdiffstats
path: root/src/charset.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-07-31 17:12:43 +0100
committerBram Moolenaar <Bram@vim.org>2022-07-31 17:12:43 +0100
commitb7963df98f9dbbb824713acad2f47c9989fcf8f3 (patch)
tree8c2476dc61f392b6524ab189f6a2e1b9558bd6a3 /src/charset.c
parent6b568b1cc75e6c4d4a3ec95d7867c7a22e98eba1 (diff)
patch 9.0.0121: cannot put virtual text after or below a linev9.0.0121
Problem: Cannot put virtual text after or below a line. Solution: Add "text_align" and "text_wrap" arguments.
Diffstat (limited to 'src/charset.c')
-rw-r--r--src/charset.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/charset.c b/src/charset.c
index f3d12cbe86..b55468fbdc 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -771,6 +771,7 @@ win_linetabsize(win_T *wp, linenr_T lnum, char_u *line, colnr_T len)
chartabsize_T cts;
init_chartabsize_arg(&cts, wp, lnum, 0, line, line);
+ cts.cts_with_trailing = len = MAXCOL;
for ( ; *cts.cts_ptr != NUL && (len == MAXCOL || cts.cts_ptr < line + len);
MB_PTR_ADV(cts.cts_ptr))
cts.cts_vcol += win_lbr_chartabsize(&cts, NULL);
@@ -1089,15 +1090,24 @@ win_lbr_chartabsize(
textprop_T *tp = cts->cts_text_props + i;
if (tp->tp_id < 0
- && tp->tp_col - 1 >= col && tp->tp_col - 1 < col + size
- && -tp->tp_id <= wp->w_buffer->b_textprop_text.ga_len)
+ && ((tp->tp_col - 1 >= col && tp->tp_col - 1 < col + size
+ && -tp->tp_id <= wp->w_buffer->b_textprop_text.ga_len)
+ || (tp->tp_col == MAXCOL && (s[0] == NUL || s[1] == NUL)
+ && cts->cts_with_trailing)))
{
char_u *p = ((char_u **)wp->w_buffer->b_textprop_text.ga_data)[
-tp->tp_id - 1];
+ int len = (int)STRLEN(p);
+
// TODO: count screen cells
- cts->cts_cur_text_width = (int)STRLEN(p);
- size += cts->cts_cur_text_width;
- break;
+ if (tp->tp_col == MAXCOL)
+ {
+ // TODO: truncating
+ if (tp->tp_flags & TP_FLAG_ALIGN_BELOW)
+ len += wp->w_width - (vcol + size) % wp->w_width;
+ }
+ cts->cts_cur_text_width += len;
+ size += len;
}
if (tp->tp_col - 1 > col)
break;