diff src/charset.c @ 29560:14b139cbec49 v9.0.0121

patch 9.0.0121: cannot put virtual text after or below a line Commit: https://github.com/vim/vim/commit/b7963df98f9dbbb824713acad2f47c9989fcf8f3 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 31 17:12:43 2022 +0100 patch 9.0.0121: cannot put virtual text after or below a line Problem: Cannot put virtual text after or below a line. Solution: Add "text_align" and "text_wrap" arguments.
author Bram Moolenaar <Bram@vim.org>
date Sun, 31 Jul 2022 18:15:03 +0200
parents 6387e75a4a6b
children a4dcf15f8014
line wrap: on
line diff
--- a/src/charset.c
+++ b/src/charset.c
@@ -771,6 +771,7 @@ win_linetabsize(win_T *wp, linenr_T lnum
     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;