Blob Blame History Raw
To: vim-dev@vim.org
Subject: patch 7.1.005
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.1.005
Problem:    "cit" used on <foo></foo> deletes <foo>.  Should not delete
	    anything and start insertion, like "ci'" does on "". (Michal
	    Bozon)
Solution:   Handle an empty object specifically.  Made it work consistent for
	    various text objects.
Files:	    src/search.c


*** ../vim-7.1.004/src/search.c	Thu May 10 20:54:46 2007
--- src/search.c	Mon Jun  4 12:31:04 2007
***************
*** 3600,3612 ****
      {
  	oap->start = start_pos;
  	oap->motion_type = MCHAR;
  	if (sol)
- 	{
  	    incl(&curwin->w_cursor);
! 	    oap->inclusive = FALSE;
! 	}
! 	else
  	    oap->inclusive = TRUE;
      }
  
      return OK;
--- 3600,3615 ----
      {
  	oap->start = start_pos;
  	oap->motion_type = MCHAR;
+ 	oap->inclusive = FALSE;
  	if (sol)
  	    incl(&curwin->w_cursor);
! 	else if (lt(start_pos, curwin->w_cursor))
! 	    /* Include the character under the cursor. */
  	    oap->inclusive = TRUE;
+ 	else
+ 	    /* End is before the start (no text in between <>, [], etc.): don't
+ 	     * operate on any text. */
+ 	    curwin->w_cursor = start_pos;
      }
  
      return OK;
***************
*** 3734,3740 ****
  
  	if (in_html_tag(FALSE))
  	{
! 	    /* cursor on start tag, move to just after it */
  	    while (*ml_get_cursor() != '>')
  		if (inc_cursor() < 0)
  		    break;
--- 3737,3743 ----
  
  	if (in_html_tag(FALSE))
  	{
! 	    /* cursor on start tag, move to its '>' */
  	    while (*ml_get_cursor() != '>')
  		if (inc_cursor() < 0)
  		    break;
***************
*** 3838,3844 ****
  	/* Exclude the start tag. */
  	curwin->w_cursor = start_pos;
  	while (inc_cursor() >= 0)
! 	    if (*ml_get_cursor() == '>' && lt(curwin->w_cursor, end_pos))
  	    {
  		inc_cursor();
  		start_pos = curwin->w_cursor;
--- 3841,3847 ----
  	/* Exclude the start tag. */
  	curwin->w_cursor = start_pos;
  	while (inc_cursor() >= 0)
! 	    if (*ml_get_cursor() == '>')
  	    {
  		inc_cursor();
  		start_pos = curwin->w_cursor;
***************
*** 3860,3866 ****
  #ifdef FEAT_VISUAL
      if (VIsual_active)
      {
! 	if (*p_sel == 'e')
  	    ++curwin->w_cursor.col;
  	VIsual = start_pos;
  	VIsual_mode = 'v';
--- 3863,3873 ----
  #ifdef FEAT_VISUAL
      if (VIsual_active)
      {
! 	/* If the end is before the start there is no text between tags, select
! 	 * the char under the cursor. */
! 	if (lt(end_pos, start_pos))
! 	    curwin->w_cursor = start_pos;
! 	else if (*p_sel == 'e')
  	    ++curwin->w_cursor.col;
  	VIsual = start_pos;
  	VIsual_mode = 'v';
***************
*** 3872,3878 ****
      {
  	oap->start = start_pos;
  	oap->motion_type = MCHAR;
! 	oap->inclusive = TRUE;
      }
      retval = OK;
  
--- 3879,3893 ----
      {
  	oap->start = start_pos;
  	oap->motion_type = MCHAR;
! 	if (lt(end_pos, start_pos))
! 	{
! 	    /* End is before the start: there is no text between tags; operate
! 	     * on an empty area. */
! 	    curwin->w_cursor = start_pos;
! 	    oap->inclusive = FALSE;
! 	}
! 	else
! 	    oap->inclusive = TRUE;
      }
      retval = OK;
  
*** ../vim-7.1.004/src/version.c	Tue Jun 19 11:54:23 2007
--- src/version.c	Tue Jun 19 12:57:03 2007
***************
*** 668,669 ****
--- 668,671 ----
  {   /* Add new patch number below this line */
+ /**/
+     5,
  /**/

-- 
Life would be so much easier if we could just look at the source code.

 /// 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    ///