changeset 29918:e6e0f1c39edb v9.0.0297

patch 9.0.0297: cursor position wrong after right aligned virtual text Commit: https://github.com/vim/vim/commit/c8bf59e9b27f9d621818ffc61468abef45cedf37 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Aug 28 16:39:22 2022 +0100 patch 9.0.0297: cursor position wrong after right aligned virtual text Problem: Cursor position wrong after right aligned virtual text. (Iizuka Masashi) Solution: Take the width of the column offset into account. (closes #10997) Also fix virtual text positioning.
author Bram Moolenaar <Bram@vim.org>
date Sun, 28 Aug 2022 17:45:03 +0200
parents a25eab5e4117
children 9abb84574c68
files src/charset.c src/drawline.c src/testdir/dumps/Test_prop_right_align_twice_3.dump src/testdir/test_textprop.vim src/version.c
diffstat 5 files changed, 25 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/charset.c
+++ b/src/charset.c
@@ -1187,7 +1187,8 @@ win_lbr_chartabsize(
 
 	for (i = 0; i < cts->cts_text_prop_count; ++i)
 	{
-	    textprop_T *tp = cts->cts_text_props + i;
+	    textprop_T	*tp = cts->cts_text_props + i;
+	    int		col_off = win_col_off(wp);
 
 	    // Watch out for the text being deleted.  "cts_text_props" is a
 	    // copy, the text prop may actually have been removed from the line.
@@ -1209,7 +1210,7 @@ win_lbr_chartabsize(
 			int n_extra = (int)STRLEN(p);
 
 			cells = text_prop_position(wp, tp,
-					    (vcol + size) % wp->w_width,
+			     (vcol + size) % (wp->w_width - col_off) + col_off,
 						     &n_extra, &p, NULL, NULL);
 #ifdef FEAT_LINEBREAK
 			no_sbr = TRUE;  // don't use 'showbreak' now
--- a/src/drawline.c
+++ b/src/drawline.c
@@ -302,6 +302,7 @@ text_prop_position(
     int	    padding = tp->tp_col == MAXCOL && tp->tp_len > 1
 				  ? tp->tp_len - 1 : 0;
     int	    col_with_padding = vcol + (below ? 0 : padding);
+    int	    col_off = 0;
     int	    room = wp->w_width - col_with_padding;
     int	    added = room;
     int	    n_used = *n_extra;
@@ -324,7 +325,8 @@ text_prop_position(
 	    if (right && (wrap || room < PROP_TEXT_MIN_CELLS))
 	    {
 		// right-align on next line instead of wrapping if possible
-		added = wp->w_width - strsize + room;
+		col_off = win_col_off(wp) + win_col_off2(wp);
+		added = wp->w_width - col_off - strsize + room;
 		if (added < 0)
 		    added = 0;
 		else
@@ -386,7 +388,7 @@ text_prop_position(
 		*p_extra = l;
 		*n_extra = n_used + added + padding;
 		*n_attr = mb_charlen(*p_extra);
-		*n_attr_skip = added + padding;
+		*n_attr_skip = added + padding + col_off;
 	    }
 	}
     }
new file mode 100644
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_right_align_twice_3.dump
@@ -0,0 +1,8 @@
+| +0#0000e05#a8a8a8255@1|s+0#0000000#ffffff0|o|m|e| |m|o|r|e| |t|e|x|t|s|o|m|e| |t|e|x|t| |s|o|m|e| |t|e|x|t| |s|o|m|e| |t|e|x|t| |s|o|m|e| |t|e|x|t| +0&#ffd7ff255|n|o|t|h|i|n|g| |h|e|r|e| +0&#ffffff0@6
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@62|S+0#ffffff16#e000002|o|m|e| |e|r@1|o|r
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@59|A+0#ffffff16#e000002|n|o|t|h|e|r| |e|r@1|o|r
+| +0#0000e05#a8a8a8255@1|l+0#0000000#ffffff0|i|n|e| |t|w>o| @64
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|2|,|8| @10|A|l@1| 
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -2574,11 +2574,11 @@ func Test_props_with_text_right_align_tw
 
   let lines =<< trim END
       call setline(1, ["some text some text some text some text", 'line two'])
-      call prop_type_add( 'MyErrorText', #{ highlight: 'ErrorMsg' } )
-      call prop_type_add( 'MyPadding', #{ highlight: 'DiffChange' } )
-      call prop_add( 1, 0, #{ type: 'MyPadding', text: ' nothing here', text_wrap: 'wrap'} )
-      call prop_add( 1, 0, #{ type: 'MyErrorText', text: 'Some error', text_wrap: 'wrap', text_align: 'right' } )
-      call prop_add( 1, 0, #{ type: 'MyErrorText', text: 'Another error', text_wrap: 'wrap', text_align: 'right' } )
+      call prop_type_add('MyErrorText', #{ highlight: 'ErrorMsg'})
+      call prop_type_add('MyPadding', #{ highlight: 'DiffChange'})
+      call prop_add(1, 0, #{type: 'MyPadding', text: ' nothing here', text_wrap: 'wrap'})
+      call prop_add(1, 0, #{type: 'MyErrorText', text: 'Some error', text_wrap: 'wrap', text_align: 'right'})
+      call prop_add(1, 0, #{type: 'MyErrorText', text: 'Another error', text_wrap: 'wrap', text_align: 'right'})
       normal G$
   END
   call writefile(lines, 'XscriptPropsRightAlign')
@@ -2588,6 +2588,9 @@ func Test_props_with_text_right_align_tw
   call term_sendkeys(buf, "ggisome more text\<Esc>G$")
   call VerifyScreenDump(buf, 'Test_prop_right_align_twice_2', {})
 
+  call term_sendkeys(buf, ":set signcolumn=yes\<CR>")
+  call VerifyScreenDump(buf, 'Test_prop_right_align_twice_3', {})
+
   call StopVimInTerminal(buf)
   call delete('XscriptPropsRightAlign')
 endfunc
--- a/src/version.c
+++ b/src/version.c
@@ -708,6 +708,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    297,
+/**/
     296,
 /**/
     295,