Blob Blame History Raw
To: vim_dev@googlegroups.com
Subject: Patch 7.4.665
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.4.665
Problem:    'linebreak' does not work properly with multi-byte characters.
Solution:   Compute the pointer offset with mb_head_off().  (Yasuhiro
	    Matsumoto)
Files:	    src/screen.c


*** ../vim-7.4.664/src/screen.c	2015-03-20 15:42:07.200377381 +0100
--- src/screen.c	2015-03-20 15:51:46.173856852 +0100
***************
*** 4484,4494 ****
  		 */
  		if (wp->w_p_lbr && vim_isbreak(c) && !vim_isbreak(*ptr))
  		{
  		    char_u *p = ptr - (
  # ifdef FEAT_MBYTE
! 				has_mbyte ? mb_l :
  # endif
  				1);
  		    /* TODO: is passing p for start of the line OK? */
  		    n_extra = win_lbr_chartabsize(wp, line, p, (colnr_T)vcol,
  								    NULL) - 1;
--- 4484,4498 ----
  		 */
  		if (wp->w_p_lbr && vim_isbreak(c) && !vim_isbreak(*ptr))
  		{
+ # ifdef FEAT_MBYTE
+ 		    int off = has_mbyte ? (*mb_head_off)(line, ptr - 1) : 0;
+ # endif
  		    char_u *p = ptr - (
  # ifdef FEAT_MBYTE
! 				off +
  # endif
  				1);
+ 
  		    /* TODO: is passing p for start of the line OK? */
  		    n_extra = win_lbr_chartabsize(wp, line, p, (colnr_T)vcol,
  								    NULL) - 1;
***************
*** 4496,4502 ****
--- 4500,4510 ----
  			n_extra = (int)wp->w_buffer->b_p_ts
  				       - vcol % (int)wp->w_buffer->b_p_ts - 1;
  
+ # ifdef FEAT_MBYTE
+ 		    c_extra = off > 0 ? MB_FILLER_CHAR : ' ';
+ # else
  		    c_extra = ' ';
+ # endif
  		    if (vim_iswhite(c))
  		    {
  #ifdef FEAT_CONCEAL
*** ../vim-7.4.664/src/version.c	2015-03-20 15:42:07.200377381 +0100
--- src/version.c	2015-03-20 15:47:29.472744102 +0100
***************
*** 743,744 ****
--- 743,746 ----
  {   /* Add new patch number below this line */
+ /**/
+     665,
  /**/

-- 
ARTHUR:  Be quiet!
DENNIS:  Well you can't expect to wield supreme executive power just 'cause
         some watery tart threw a sword at you!
ARTHUR:  Shut up!
DENNIS:  I mean, if I went around sayin' I was an empereror just because some
         moistened bint had lobbed a scimitar at me they'd put me away!
                                  The Quest for the Holy Grail (Monty Python)

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///