Patch 9.0.0297
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.
Files:      src/charset.c, src/drawline.c, src/testdir/test_textprop.vim,
            src/testdir/dumps/Test_prop_right_align_twice_3.dump


*** ../vim-9.0.0296/src/charset.c       2022-08-23 18:39:14.756797669 +0100
--- src/charset.c       2022-08-28 16:24:46.327837824 +0100
***************
*** 1187,1193 ****
  
        for (i = 0; i < cts->cts_text_prop_count; ++i)
        {
!           textprop_T *tp = cts->cts_text_props + i;
  
            // Watch out for the text being deleted.  "cts_text_props" is a
            // copy, the text prop may actually have been removed from the line.
--- 1187,1194 ----
  
        for (i = 0; i < cts->cts_text_prop_count; ++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,1215 ****
                        int n_extra = (int)STRLEN(p);
  
                        cells = text_prop_position(wp, tp,
!                                           (vcol + size) % wp->w_width,
                                                     &n_extra, &p, NULL, NULL);
  #ifdef FEAT_LINEBREAK
                        no_sbr = TRUE;  // don't use 'showbreak' now
--- 1210,1216 ----
                        int n_extra = (int)STRLEN(p);
  
                        cells = text_prop_position(wp, tp,
!                            (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
*** ../vim-9.0.0296/src/drawline.c      2022-08-23 18:39:14.756797669 +0100
--- src/drawline.c      2022-08-28 16:35:47.088573767 +0100
***************
*** 302,307 ****
--- 302,308 ----
      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,330 ****
            if (right && (wrap || room < PROP_TEXT_MIN_CELLS))
            {
                // right-align on next line instead of wrapping if possible
!               added = wp->w_width - strsize + room;
                if (added < 0)
                    added = 0;
                else
--- 325,332 ----
            if (right && (wrap || room < PROP_TEXT_MIN_CELLS))
            {
                // right-align on next line instead of wrapping if possible
!               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,392 ****
                *p_extra = l;
                *n_extra = n_used + added + padding;
                *n_attr = mb_charlen(*p_extra);
!               *n_attr_skip = added + padding;
            }
        }
      }
--- 388,394 ----
                *p_extra = l;
                *n_extra = n_used + added + padding;
                *n_attr = mb_charlen(*p_extra);
!               *n_attr_skip = added + padding + col_off;
            }
        }
      }
*** ../vim-9.0.0296/src/testdir/test_textprop.vim       2022-08-24 
12:24:04.295387720 +0100
--- src/testdir/test_textprop.vim       2022-08-28 16:30:41.288362320 +0100
***************
*** 2574,2584 ****
  
    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' } )
        normal G$
    END
    call writefile(lines, 'XscriptPropsRightAlign')
--- 2574,2584 ----
  
    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'})
        normal G$
    END
    call writefile(lines, 'XscriptPropsRightAlign')
***************
*** 2588,2593 ****
--- 2588,2596 ----
    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
*** ../vim-9.0.0296/src/testdir/dumps/Test_prop_right_align_twice_3.dump        
2022-08-28 16:38:27.816633507 +0100
--- src/testdir/dumps/Test_prop_right_align_twice_3.dump        2022-08-28 
16:35:55.804577736 +0100
***************
*** 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| 
*** ../vim-9.0.0296/src/version.c       2022-08-28 14:39:34.355253105 +0100
--- src/version.c       2022-08-28 16:36:54.488602136 +0100
***************
*** 709,710 ****
--- 709,712 ----
  {   /* Add new patch number below this line */
+ /**/
+     297,
  /**/

-- 
JOHN CLEESE PLAYED: SECOND SOLDIER WITH A KEEN INTEREST IN BIRDS, LARGE MAN
                    WITH DEAD BODY, BLACK KNIGHT, MR NEWT (A VILLAGE
                    BLACKSMITH INTERESTED IN BURNING WITCHES), A QUITE
                    EXTRAORDINARILY RUDE FRENCHMAN, TIM THE WIZARD, SIR
                    LAUNCELOT
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220828154915.EC47D1C07CD%40moolenaar.net.

Raspunde prin e-mail lui