Patch 9.0.1463
Problem:    Virtual text truncation only works with Unicode 'encoding'.
Solution:   Convert the ellipsis character to 'encoding' if needed. (Hirohito
            Higashi, closes #12233)
Files:      src/drawline.c, src/testdir/test_textprop.vim,
            src/testdir/dumps/Test_prop_with_text_after_trunc_ambiw_d_1.dump,
            src/testdir/dumps/Test_prop_with_text_after_trunc_not_utf8.dump


*** ../vim-9.0.1462/src/drawline.c      2023-03-02 18:49:05.989526230 +0000
--- src/drawline.c      2023-04-17 21:42:00.308625806 +0100
***************
*** 739,748 ****
  
                    if (has_mbyte)
                    {
!                       // change last character to '…'
                        lp -= (*mb_head_off)(l, lp);
!                       STRCPY(lp, "…");
                        n_used = lp - l + 3 - before - padding;
                    }
                    else
                        // change last character to '>'
--- 739,775 ----
  
                    if (has_mbyte)
                    {
!                       char_u  buf[MB_MAXBYTES + 1];
!                       char_u  *cp = buf;
! 
!                       // change the last character to '…', converted to the
!                       // current 'encoding'
!                       STRCPY(buf, "…");
!                       if (!enc_utf8)
!                       {
!                           vimconv_T   vc;
! 
!                           vc.vc_type = CONV_NONE;
!                           convert_setup(&vc, (char_u *)"utf-8", p_enc);
!                           if (vc.vc_type != CONV_NONE)
!                           {
!                               cp = string_convert(&vc, buf, NULL);
!                               if (cp == NULL)
!                               {
!                                   // when conversion fails use '>'
!                                   cp = buf;
!                                   STRCPY(buf, ">");
!                               }
!                               convert_setup(&vc, NULL, NULL);
!                           }
!                       }
! 
!                       lp -= (*mb_ptr2cells)(cp) - 1;
                        lp -= (*mb_head_off)(l, lp);
!                       STRCPY(lp, cp);
                        n_used = lp - l + 3 - before - padding;
+                       if (cp != buf)
+                           vim_free(cp);
                    }
                    else
                        // change last character to '>'
*** ../vim-9.0.1462/src/testdir/test_textprop.vim       2023-04-14 
21:54:21.096430659 +0100
--- src/testdir/test_textprop.vim       2023-04-17 21:35:30.549948593 +0100
***************
*** 2949,2954 ****
--- 2949,3005 ----
    call StopVimInTerminal(buf)
  endfunc
  
+ func Test_props_with_text_after_truncated_and_ambiwidth_is_double()
+   CheckRunVimInTerminal
+ 
+   let lines =<< trim END
+       set ambiwidth=double
+       call setline(1, ['one two three four five six seven'])
+       call prop_type_add('afterprop', #{highlight: 'Search'})
+       call prop_add(1, 0, #{type: 'afterprop', text: ' ONE and TWO and THREE 
and FOUR and FIVE'})
+ 
+       call setline(2, ['one two three four five six seven'])
+       call prop_add(2, 0, #{type: 'afterprop', text: ' one AND two AND three 
AND four AND five', text_align: 'right'})
+ 
+       call setline(3, ['one two three four five six seven'])
+       call prop_add(3, 0, #{type: 'afterprop', text: ' one AND two AND three 
AND four AND five lets wrap after some more text', text_align: 'below'})
+ 
+       call setline(4, ['cursor here'])
+       normal 4Gfh
+   END
+   call writefile(lines, 
'XscriptPropsWithTextAfterTrunc-and-ambiwidth-is-double', 'D')
+   let buf = RunVimInTerminal('-S 
XscriptPropsWithTextAfterTrunc-and-ambiwidth-is-double', #{rows: 9, cols: 60})
+   call VerifyScreenDump(buf, 'Test_prop_with_text_after_trunc_ambiw_d_1', {})
+ 
+   call StopVimInTerminal(buf)
+ endfunc
+ 
+ 
+ func Test_props_with_text_after_truncated_not_utf8()
+   CheckRunVimInTerminal
+ 
+   let lines =<< trim END
+       set enc=cp932 tenc=utf-8
+       call setline(1, ['one two three four five six seven'])
+       call prop_type_add('afterprop', #{highlight: 'Search'})
+       call prop_add(1, 0, #{type: 'afterprop', text: ' ONE and TWO and THREE 
and FOUR and FIVE'})
+ 
+       call setline(2, ['one two three four five six seven'])
+       call prop_add(2, 0, #{type: 'afterprop', text: ' one AND two AND three 
AND four AND five', text_align: 'right'})
+ 
+       call setline(3, ['one two three four five six seven'])
+       call prop_add(3, 0, #{type: 'afterprop', text: ' one AND two AND three 
AND four AND five lets wrap after some more text', text_align: 'below'})
+ 
+       call setline(4, ['cursor here'])
+       normal 4Gfh
+   END
+   call writefile(lines, 'XscriptPropsWithTextAfterTrunc-enc-is-not-utf8', 'D')
+   let buf = RunVimInTerminal('-S 
XscriptPropsWithTextAfterTrunc-enc-is-not-utf8', #{rows: 9, cols: 60})
+   call VerifyScreenDump(buf, 'Test_prop_with_text_after_trunc_not_utf8', {})
+ 
+   call StopVimInTerminal(buf)
+ endfunc
+ 
  func Test_props_with_text_empty_line()
    CheckRunVimInTerminal
  
*** 
../vim-9.0.1462/src/testdir/dumps/Test_prop_with_text_after_trunc_ambiw_d_1.dump
    2023-04-17 21:43:35.332399035 +0100
--- src/testdir/dumps/Test_prop_with_text_after_trunc_ambiw_d_1.dump    
2023-04-17 21:29:05.751803131 +0100
***************
*** 0 ****
--- 1,9 ----
+ |o+0&#ffffff0|n|e| |t|w|o| |t|h|r|e@1| |f|o|u|r| |f|i|v|e| |s|i|x| 
|s|e|v|e|n| +0&#ffff4012|O|N|E| |a|n|d| |T|W|O| |a|n|d| |T|H|R|E@1| |a|n|…| 
+ |o+0&#ffffff0|n|e| |t|w|o| |t|h|r|e@1| |f|o|u|r| |f|i|v|e| |s|i|x| 
|s|e|v|e|n| +0&#ffff4012|o|n|e| |A|N|D| |t|w|o| |A|N|D| |t|h|r|e@1| |A|N|…| 
+ |o+0&#ffffff0|n|e| |t|w|o| |t|h|r|e@1| |f|o|u|r| |f|i|v|e| |s|i|x| 
|s|e|v|e|n| @26
+ | +0&#ffff4012|o|n|e| |A|N|D| |t|w|o| |A|N|D| |t|h|r|e@1| |A|N|D| |f|o|u|r| 
|A|N|D| |f|i|v|e| |l|e|t|s| |w|r|a|p| |a|f|t|e|r| |s|…| 
+ |c+0&#ffffff0|u|r|s|o|r| >h|e|r|e| @48
+ |~+0#4040ff13&| @58
+ |~| @58
+ |~| @58
+ | +0#0000000&@41|4|,|8| @10|A|l@1| 
*** 
../vim-9.0.1462/src/testdir/dumps/Test_prop_with_text_after_trunc_not_utf8.dump 
    2023-04-17 21:43:35.336399026 +0100
--- src/testdir/dumps/Test_prop_with_text_after_trunc_not_utf8.dump     
2023-04-17 21:29:05.751803131 +0100
***************
*** 0 ****
--- 1,9 ----
+ |o+0&#ffffff0|n|e| |t|w|o| |t|h|r|e@1| |f|o|u|r| |f|i|v|e| |s|i|x| 
|s|e|v|e|n| +0&#ffff4012|O|N|E| |a|n|d| |T|W|O| |a|n|d| |T|H|R|E@1| |a|n|…| 
+0&#ffffff0
+ |o|n|e| |t|w|o| |t|h|r|e@1| |f|o|u|r| |f|i|v|e| |s|i|x| |s|e|v|e|n| 
+0&#ffff4012|o|n|e| |A|N|D| |t|w|o| |A|N|D| |t|h|r|e@1| |A|N|…| +0&#ffffff0
+ |o|n|e| |t|w|o| |t|h|r|e@1| |f|o|u|r| |f|i|v|e| |s|i|x| |s|e|v|e|n| @26
+ | +0&#ffff4012|o|n|e| |A|N|D| |t|w|o| |A|N|D| |t|h|r|e@1| |A|N|D| |f|o|u|r| 
|A|N|D| |f|i|v|e| |l|e|t|s| |w|r|a|p| |a|f|t|e|r| |s|…| +0&#ffffff0
+ |c|u|r|s|o|r| >h|e|r|e| @48
+ |~+0#4040ff13&| @58
+ |~| @58
+ |~| @58
+ | +0#0000000&@41|4|,|8| @10|A|l@1| 
*** ../vim-9.0.1462/src/version.c       2023-04-17 19:23:41.946037074 +0100
--- src/version.c       2023-04-17 21:31:06.987432972 +0100
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1463,
  /**/

-- 
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us.     (Calvin)

 /// 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/20230417204527.D366A1C042F%40moolenaar.net.

Raspunde prin e-mail lui