Karsten Hopp fd27d2
To: vim-dev@vim.org
Karsten Hopp fd27d2
Subject: Patch 7.0.013
Karsten Hopp fd27d2
Fcc: outbox
Karsten Hopp fd27d2
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp fd27d2
Mime-Version: 1.0
Karsten Hopp fd27d2
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp fd27d2
Content-Transfer-Encoding: 8bit
Karsten Hopp fd27d2
------------
Karsten Hopp fd27d2
Karsten Hopp fd27d2
Patch 7.0.013
Karsten Hopp fd27d2
Problem:    Insert mode completion: using CTRL-L to add an extra character
Karsten Hopp fd27d2
	    also deselects the current match, making it impossible to use
Karsten Hopp fd27d2
	    CTRL-L a second time.
Karsten Hopp fd27d2
Solution:   Keep the current match.  Also make CTRL-L work at the original
Karsten Hopp fd27d2
	    text, using the first displayed match.
Karsten Hopp fd27d2
Files:	    src/edit.c
Karsten Hopp fd27d2
Karsten Hopp fd27d2
Karsten Hopp fd27d2
*** ../vim-7.0.012/src/edit.c	Wed May 10 15:22:49 2006
Karsten Hopp fd27d2
--- src/edit.c	Thu May 11 10:38:54 2006
Karsten Hopp fd27d2
***************
Karsten Hopp fd27d2
*** 751,757 ****
Karsten Hopp fd27d2
  		    continue;
Karsten Hopp fd27d2
  		}
Karsten Hopp fd27d2
  
Karsten Hopp fd27d2
! 		/* Pressing CTRL-Y selects the current match.  Shen
Karsten Hopp fd27d2
  		 * compl_enter_selects is set the Enter key does the same. */
Karsten Hopp fd27d2
  		if (c == Ctrl_Y || (compl_enter_selects
Karsten Hopp fd27d2
  				   && (c == CAR || c == K_KENTER || c == NL)))
Karsten Hopp fd27d2
--- 751,757 ----
Karsten Hopp fd27d2
  		    continue;
Karsten Hopp fd27d2
  		}
Karsten Hopp fd27d2
  
Karsten Hopp fd27d2
! 		/* Pressing CTRL-Y selects the current match.  When
Karsten Hopp fd27d2
  		 * compl_enter_selects is set the Enter key does the same. */
Karsten Hopp fd27d2
  		if (c == Ctrl_Y || (compl_enter_selects
Karsten Hopp fd27d2
  				   && (c == CAR || c == K_KENTER || c == NL)))
Karsten Hopp fd27d2
***************
Karsten Hopp fd27d2
*** 3046,3052 ****
Karsten Hopp fd27d2
      ins_compl_delete();
Karsten Hopp fd27d2
      ins_bytes(compl_leader + curwin->w_cursor.col - compl_col);
Karsten Hopp fd27d2
      compl_used_match = FALSE;
Karsten Hopp fd27d2
-     compl_enter_selects = FALSE;
Karsten Hopp fd27d2
  
Karsten Hopp fd27d2
      if (compl_started)
Karsten Hopp fd27d2
  	ins_compl_set_original_text(compl_leader);
Karsten Hopp fd27d2
--- 3046,3051 ----
Karsten Hopp fd27d2
***************
Karsten Hopp fd27d2
*** 3076,3081 ****
Karsten Hopp fd27d2
--- 3075,3081 ----
Karsten Hopp fd27d2
  	compl_restarting = FALSE;
Karsten Hopp fd27d2
      }
Karsten Hopp fd27d2
  
Karsten Hopp fd27d2
+ #if 0   /* disabled, made CTRL-L, BS and typing char jump to original text. */
Karsten Hopp fd27d2
      if (!compl_used_match)
Karsten Hopp fd27d2
      {
Karsten Hopp fd27d2
  	/* Go to the original text, since none of the matches is inserted. */
Karsten Hopp fd27d2
***************
Karsten Hopp fd27d2
*** 3087,3092 ****
Karsten Hopp fd27d2
--- 3087,3094 ----
Karsten Hopp fd27d2
  	compl_curr_match = compl_shown_match;
Karsten Hopp fd27d2
  	compl_shows_dir = compl_direction;
Karsten Hopp fd27d2
      }
Karsten Hopp fd27d2
+ #endif
Karsten Hopp fd27d2
+     compl_enter_selects = !compl_used_match;
Karsten Hopp fd27d2
  
Karsten Hopp fd27d2
      /* Show the popup menu with a different set of matches. */
Karsten Hopp fd27d2
      ins_compl_show_pum();
Karsten Hopp fd27d2
***************
Karsten Hopp fd27d2
*** 3175,3184 ****
Karsten Hopp fd27d2
      char_u	*p;
Karsten Hopp fd27d2
      int		len = curwin->w_cursor.col - compl_col;
Karsten Hopp fd27d2
      int		c;
Karsten Hopp fd27d2
  
Karsten Hopp fd27d2
      p = compl_shown_match->cp_str;
Karsten Hopp fd27d2
      if ((int)STRLEN(p) <= len)   /* the match is too short */
Karsten Hopp fd27d2
! 	return;
Karsten Hopp fd27d2
      p += len;
Karsten Hopp fd27d2
  #ifdef FEAT_MBYTE
Karsten Hopp fd27d2
      c = mb_ptr2char(p);
Karsten Hopp fd27d2
--- 3177,3208 ----
Karsten Hopp fd27d2
      char_u	*p;
Karsten Hopp fd27d2
      int		len = curwin->w_cursor.col - compl_col;
Karsten Hopp fd27d2
      int		c;
Karsten Hopp fd27d2
+     compl_T	*cp;
Karsten Hopp fd27d2
  
Karsten Hopp fd27d2
      p = compl_shown_match->cp_str;
Karsten Hopp fd27d2
      if ((int)STRLEN(p) <= len)   /* the match is too short */
Karsten Hopp fd27d2
!     {
Karsten Hopp fd27d2
! 	/* When still at the original match use the first entry that matches
Karsten Hopp fd27d2
! 	 * the leader. */
Karsten Hopp fd27d2
! 	if (compl_shown_match->cp_flags & ORIGINAL_TEXT)
Karsten Hopp fd27d2
! 	{
Karsten Hopp fd27d2
! 	    p = NULL;
Karsten Hopp fd27d2
! 	    for (cp = compl_shown_match->cp_next; cp != NULL
Karsten Hopp fd27d2
! 				 && cp != compl_first_match; cp = cp->cp_next)
Karsten Hopp fd27d2
! 	    {
Karsten Hopp fd27d2
! 		if (ins_compl_equal(cp, compl_leader,
Karsten Hopp fd27d2
! 						   (int)STRLEN(compl_leader)))
Karsten Hopp fd27d2
! 		{
Karsten Hopp fd27d2
! 		    p = cp->cp_str;
Karsten Hopp fd27d2
! 		    break;
Karsten Hopp fd27d2
! 		}
Karsten Hopp fd27d2
! 	    }
Karsten Hopp fd27d2
! 	    if (p == NULL || (int)STRLEN(p) <= len)
Karsten Hopp fd27d2
! 		return;
Karsten Hopp fd27d2
! 	}
Karsten Hopp fd27d2
! 	else
Karsten Hopp fd27d2
! 	    return;
Karsten Hopp fd27d2
!     }
Karsten Hopp fd27d2
      p += len;
Karsten Hopp fd27d2
  #ifdef FEAT_MBYTE
Karsten Hopp fd27d2
      c = mb_ptr2char(p);
Karsten Hopp fd27d2
***************
Karsten Hopp fd27d2
*** 4100,4105 ****
Karsten Hopp fd27d2
--- 4124,4144 ----
Karsten Hopp fd27d2
  		&& compl_shown_match->cp_next != NULL
Karsten Hopp fd27d2
  		&& compl_shown_match->cp_next != compl_first_match)
Karsten Hopp fd27d2
  	    compl_shown_match = compl_shown_match->cp_next;
Karsten Hopp fd27d2
+ 
Karsten Hopp fd27d2
+ 	/* If we didn't find it searching forward, and compl_shows_dir is
Karsten Hopp fd27d2
+ 	 * backward, find the last match. */
Karsten Hopp fd27d2
+ 	if (compl_shows_dir == BACKWARD
Karsten Hopp fd27d2
+ 		&& !ins_compl_equal(compl_shown_match,
Karsten Hopp fd27d2
+ 				      compl_leader, (int)STRLEN(compl_leader))
Karsten Hopp fd27d2
+ 		&& (compl_shown_match->cp_next == NULL
Karsten Hopp fd27d2
+ 		    || compl_shown_match->cp_next == compl_first_match))
Karsten Hopp fd27d2
+ 	{
Karsten Hopp fd27d2
+ 	    while (!ins_compl_equal(compl_shown_match,
Karsten Hopp fd27d2
+ 				      compl_leader, (int)STRLEN(compl_leader))
Karsten Hopp fd27d2
+ 		    && compl_shown_match->cp_prev != NULL
Karsten Hopp fd27d2
+ 		    && compl_shown_match->cp_prev != compl_first_match)
Karsten Hopp fd27d2
+ 		compl_shown_match = compl_shown_match->cp_prev;
Karsten Hopp fd27d2
+ 	}
Karsten Hopp fd27d2
      }
Karsten Hopp fd27d2
  
Karsten Hopp fd27d2
      if (allow_get_expansion && insert_match
Karsten Hopp fd27d2
*** ../vim-7.0.012/src/version.c	Thu May 11 19:30:09 2006
Karsten Hopp fd27d2
--- src/version.c	Fri May 12 19:03:32 2006
Karsten Hopp fd27d2
***************
Karsten Hopp fd27d2
*** 668,669 ****
Karsten Hopp fd27d2
--- 668,671 ----
Karsten Hopp fd27d2
  {   /* Add new patch number below this line */
Karsten Hopp fd27d2
+ /**/
Karsten Hopp fd27d2
+     13,
Karsten Hopp fd27d2
  /**/
Karsten Hopp fd27d2
Karsten Hopp fd27d2
-- 
Karsten Hopp fd27d2
I'm writing a book.  I've got the page numbers done.
Karsten Hopp fd27d2
Karsten Hopp fd27d2
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp fd27d2
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp fd27d2
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp fd27d2
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///