840d0cb
To: vim-dev@vim.org
840d0cb
Subject: patch 7.1.005
840d0cb
Fcc: outbox
840d0cb
From: Bram Moolenaar <Bram@moolenaar.net>
840d0cb
Mime-Version: 1.0
840d0cb
Content-Type: text/plain; charset=ISO-8859-1
840d0cb
Content-Transfer-Encoding: 8bit
840d0cb
------------
840d0cb
840d0cb
Patch 7.1.005
840d0cb
Problem:    "cit" used on <foo></foo> deletes <foo>.  Should not delete
840d0cb
	    anything and start insertion, like "ci'" does on "". (Michal
840d0cb
	    Bozon)
840d0cb
Solution:   Handle an empty object specifically.  Made it work consistent for
840d0cb
	    various text objects.
840d0cb
Files:	    src/search.c
840d0cb
840d0cb
840d0cb
*** ../vim-7.1.004/src/search.c	Thu May 10 20:54:46 2007
840d0cb
--- src/search.c	Mon Jun  4 12:31:04 2007
840d0cb
***************
840d0cb
*** 3600,3612 ****
840d0cb
      {
840d0cb
  	oap->start = start_pos;
840d0cb
  	oap->motion_type = MCHAR;
840d0cb
  	if (sol)
840d0cb
- 	{
840d0cb
  	    incl(&curwin->w_cursor);
840d0cb
! 	    oap->inclusive = FALSE;
840d0cb
! 	}
840d0cb
! 	else
840d0cb
  	    oap->inclusive = TRUE;
840d0cb
      }
840d0cb
  
840d0cb
      return OK;
840d0cb
--- 3600,3615 ----
840d0cb
      {
840d0cb
  	oap->start = start_pos;
840d0cb
  	oap->motion_type = MCHAR;
840d0cb
+ 	oap->inclusive = FALSE;
840d0cb
  	if (sol)
840d0cb
  	    incl(&curwin->w_cursor);
840d0cb
! 	else if (lt(start_pos, curwin->w_cursor))
840d0cb
! 	    /* Include the character under the cursor. */
840d0cb
  	    oap->inclusive = TRUE;
840d0cb
+ 	else
840d0cb
+ 	    /* End is before the start (no text in between <>, [], etc.): don't
840d0cb
+ 	     * operate on any text. */
840d0cb
+ 	    curwin->w_cursor = start_pos;
840d0cb
      }
840d0cb
  
840d0cb
      return OK;
840d0cb
***************
840d0cb
*** 3734,3740 ****
840d0cb
  
840d0cb
  	if (in_html_tag(FALSE))
840d0cb
  	{
840d0cb
! 	    /* cursor on start tag, move to just after it */
840d0cb
  	    while (*ml_get_cursor() != '>')
840d0cb
  		if (inc_cursor() < 0)
840d0cb
  		    break;
840d0cb
--- 3737,3743 ----
840d0cb
  
840d0cb
  	if (in_html_tag(FALSE))
840d0cb
  	{
840d0cb
! 	    /* cursor on start tag, move to its '>' */
840d0cb
  	    while (*ml_get_cursor() != '>')
840d0cb
  		if (inc_cursor() < 0)
840d0cb
  		    break;
840d0cb
***************
840d0cb
*** 3838,3844 ****
840d0cb
  	/* Exclude the start tag. */
840d0cb
  	curwin->w_cursor = start_pos;
840d0cb
  	while (inc_cursor() >= 0)
840d0cb
! 	    if (*ml_get_cursor() == '>' && lt(curwin->w_cursor, end_pos))
840d0cb
  	    {
840d0cb
  		inc_cursor();
840d0cb
  		start_pos = curwin->w_cursor;
840d0cb
--- 3841,3847 ----
840d0cb
  	/* Exclude the start tag. */
840d0cb
  	curwin->w_cursor = start_pos;
840d0cb
  	while (inc_cursor() >= 0)
840d0cb
! 	    if (*ml_get_cursor() == '>')
840d0cb
  	    {
840d0cb
  		inc_cursor();
840d0cb
  		start_pos = curwin->w_cursor;
840d0cb
***************
840d0cb
*** 3860,3866 ****
840d0cb
  #ifdef FEAT_VISUAL
840d0cb
      if (VIsual_active)
840d0cb
      {
840d0cb
! 	if (*p_sel == 'e')
840d0cb
  	    ++curwin->w_cursor.col;
840d0cb
  	VIsual = start_pos;
840d0cb
  	VIsual_mode = 'v';
840d0cb
--- 3863,3873 ----
840d0cb
  #ifdef FEAT_VISUAL
840d0cb
      if (VIsual_active)
840d0cb
      {
840d0cb
! 	/* If the end is before the start there is no text between tags, select
840d0cb
! 	 * the char under the cursor. */
840d0cb
! 	if (lt(end_pos, start_pos))
840d0cb
! 	    curwin->w_cursor = start_pos;
840d0cb
! 	else if (*p_sel == 'e')
840d0cb
  	    ++curwin->w_cursor.col;
840d0cb
  	VIsual = start_pos;
840d0cb
  	VIsual_mode = 'v';
840d0cb
***************
840d0cb
*** 3872,3878 ****
840d0cb
      {
840d0cb
  	oap->start = start_pos;
840d0cb
  	oap->motion_type = MCHAR;
840d0cb
! 	oap->inclusive = TRUE;
840d0cb
      }
840d0cb
      retval = OK;
840d0cb
  
840d0cb
--- 3879,3893 ----
840d0cb
      {
840d0cb
  	oap->start = start_pos;
840d0cb
  	oap->motion_type = MCHAR;
840d0cb
! 	if (lt(end_pos, start_pos))
840d0cb
! 	{
840d0cb
! 	    /* End is before the start: there is no text between tags; operate
840d0cb
! 	     * on an empty area. */
840d0cb
! 	    curwin->w_cursor = start_pos;
840d0cb
! 	    oap->inclusive = FALSE;
840d0cb
! 	}
840d0cb
! 	else
840d0cb
! 	    oap->inclusive = TRUE;
840d0cb
      }
840d0cb
      retval = OK;
840d0cb
  
840d0cb
*** ../vim-7.1.004/src/version.c	Tue Jun 19 11:54:23 2007
840d0cb
--- src/version.c	Tue Jun 19 12:57:03 2007
840d0cb
***************
840d0cb
*** 668,669 ****
840d0cb
--- 668,671 ----
840d0cb
  {   /* Add new patch number below this line */
840d0cb
+ /**/
840d0cb
+     5,
840d0cb
  /**/
840d0cb
840d0cb
-- 
840d0cb
Life would be so much easier if we could just look at the source code.
840d0cb
840d0cb
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
840d0cb
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
840d0cb
\\\        download, build and distribute -- http://www.A-A-P.org        ///
840d0cb
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///