Blob Blame History Raw
To: vim-dev@vim.org
Subject: patch 7.0.199
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------

Patch 7.0.199
Problem:    When using multi-byte characters the combination of completion and
            formatting may result in a wrong cursor position.
Solution:   Don't decrement the cursor column, use dec_cursor(). (Yukihiro
            Nakadaira)  Also check for the column to be zero.
Files:      src/edit.c


*** ../vim-7.0.198/src/edit.c	Sun Feb  4 02:37:40 2007
--- src/edit.c	Fri Feb 16 01:15:49 2007
***************
*** 3448,3458 ****
  	    }
  	    else
  	    {
  		/* put the cursor on the last char, for 'tw' formatting */
! 		curwin->w_cursor.col--;
  		if (stop_arrow() == OK)
  		    insertchar(NUL, 0, -1);
! 		curwin->w_cursor.col++;
  	    }
  
  	    auto_format(FALSE, TRUE);
--- 3449,3464 ----
  	    }
  	    else
  	    {
+ 		int prev_col = curwin->w_cursor.col;
+ 
  		/* put the cursor on the last char, for 'tw' formatting */
! 		if (prev_col > 0)
! 		    dec_cursor();
  		if (stop_arrow() == OK)
  		    insertchar(NUL, 0, -1);
! 		if (prev_col > 0
! 			     && ml_get_curline()[curwin->w_cursor.col] != NUL)
! 		    inc_cursor();
  	    }
  
  	    auto_format(FALSE, TRUE);
*** ../vim-7.0.198/src/version.c	Tue Feb 20 03:18:20 2007
--- src/version.c	Tue Feb 20 03:32:12 2007
***************
*** 668,669 ****
--- 668,671 ----
  {   /* Add new patch number below this line */
+ /**/
+     199,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
156. You forget your friend's name but not her e-mail address.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///