f063954
To: vim-dev@vim.org
f063954
Subject: Patch 7.0.035
f063954
Fcc: outbox
f063954
From: Bram Moolenaar <Bram@moolenaar.net>
f063954
Mime-Version: 1.0
f063954
Content-Type: text/plain; charset=ISO-8859-1
f063954
Content-Transfer-Encoding: 8bit
f063954
------------
f063954
f063954
Patch 7.0.035
f063954
Problem:    Insert mode completion works when typed but not when replayed from
f063954
	    a register. (Hari Krishna Dara)
f063954
	    Also: Mappings for Insert mode completion don't always work.
f063954
Solution:   When finding a non-completion key in the input don't interrupt
f063954
	    completion when it wasn't typed.
f063954
	    Do use mappings when checking for typeahead while still finding
f063954
	    completions.  Avoids that completion is interrupted too soon.
f063954
	    Use "compl_pending" in a different way.
f063954
Files:	    src/edit.c
f063954
f063954
f063954
*** ../vim-7.0.034/src/edit.c	Fri Jun 23 17:59:26 2006
f063954
--- src/edit.c	Fri Jun 23 21:32:42 2006
f063954
***************
f063954
*** 4166,4173 ****
f063954
      {
f063954
  	if (compl_shows_dir == FORWARD && compl_shown_match->cp_next != NULL)
f063954
  	{
f063954
- 	    if (compl_pending != 0)
f063954
- 		--compl_pending;
f063954
  	    compl_shown_match = compl_shown_match->cp_next;
f063954
  	    found_end = (compl_first_match != NULL
f063954
  			   && (compl_shown_match->cp_next == compl_first_match
f063954
--- 4166,4171 ----
f063954
***************
f063954
*** 4176,4189 ****
f063954
  	else if (compl_shows_dir == BACKWARD
f063954
  					&& compl_shown_match->cp_prev != NULL)
f063954
  	{
f063954
- 	    if (compl_pending != 0)
f063954
- 		++compl_pending;
f063954
  	    found_end = (compl_shown_match == compl_first_match);
f063954
  	    compl_shown_match = compl_shown_match->cp_prev;
f063954
  	    found_end |= (compl_shown_match == compl_first_match);
f063954
  	}
f063954
  	else
f063954
  	{
f063954
  	    if (advance)
f063954
  	    {
f063954
  		if (compl_shows_dir == BACKWARD)
f063954
--- 4174,4197 ----
f063954
  	else if (compl_shows_dir == BACKWARD
f063954
  					&& compl_shown_match->cp_prev != NULL)
f063954
  	{
f063954
  	    found_end = (compl_shown_match == compl_first_match);
f063954
  	    compl_shown_match = compl_shown_match->cp_prev;
f063954
  	    found_end |= (compl_shown_match == compl_first_match);
f063954
  	}
f063954
  	else
f063954
  	{
f063954
+ 	    if (!allow_get_expansion)
f063954
+ 	    {
f063954
+ 		if (advance)
f063954
+ 		{
f063954
+ 		    if (compl_shows_dir == BACKWARD)
f063954
+ 			compl_pending -= todo + 1;
f063954
+ 		    else
f063954
+ 			compl_pending += todo + 1;
f063954
+ 		}
f063954
+ 		return -1;
f063954
+ 	    }
f063954
+ 
f063954
  	    if (advance)
f063954
  	    {
f063954
  		if (compl_shows_dir == BACKWARD)
f063954
***************
f063954
*** 4191,4204 ****
f063954
  		else
f063954
  		    ++compl_pending;
f063954
  	    }
f063954
- 	    if (!allow_get_expansion)
f063954
- 		return -1;
f063954
  
f063954
  	    /* Find matches. */
f063954
  	    num_matches = ins_compl_get_exp(&compl_startpos);
f063954
! 	    if (compl_pending != 0 && compl_direction == compl_shows_dir
f063954
  								   && advance)
f063954
! 		compl_shown_match = compl_curr_match;
f063954
  	    found_end = FALSE;
f063954
  	}
f063954
  	if ((compl_shown_match->cp_flags & ORIGINAL_TEXT) == 0
f063954
--- 4199,4225 ----
f063954
  		else
f063954
  		    ++compl_pending;
f063954
  	    }
f063954
  
f063954
  	    /* Find matches. */
f063954
  	    num_matches = ins_compl_get_exp(&compl_startpos);
f063954
! 
f063954
! 	    /* handle any pending completions */
f063954
! 	    while (compl_pending != 0 && compl_direction == compl_shows_dir
f063954
  								   && advance)
f063954
! 	    {
f063954
! 		if (compl_pending > 0 && compl_shown_match->cp_next != NULL)
f063954
! 		{
f063954
! 		    compl_shown_match = compl_shown_match->cp_next;
f063954
! 		    --compl_pending;
f063954
! 		}
f063954
! 		if (compl_pending < 0 && compl_shown_match->cp_prev != NULL)
f063954
! 		{
f063954
! 		    compl_shown_match = compl_shown_match->cp_prev;
f063954
! 		    ++compl_pending;
f063954
! 		}
f063954
! 		else
f063954
! 		    break;
f063954
! 	    }
f063954
  	    found_end = FALSE;
f063954
  	}
f063954
  	if ((compl_shown_match->cp_flags & ORIGINAL_TEXT) == 0
f063954
***************
f063954
*** 4307,4315 ****
f063954
  	return;
f063954
      count = 0;
f063954
  
f063954
!     ++no_mapping;
f063954
      c = vpeekc_any();
f063954
-     --no_mapping;
f063954
      if (c != NUL)
f063954
      {
f063954
  	if (vim_is_ctrl_x_key(c) && c != Ctrl_X && c != Ctrl_R)
f063954
--- 4328,4336 ----
f063954
  	return;
f063954
      count = 0;
f063954
  
f063954
!     /* Check for a typed key.  Do use mappings, otherwise vim_is_ctrl_x_key()
f063954
!      * can't do its work correctly. */
f063954
      c = vpeekc_any();
f063954
      if (c != NUL)
f063954
      {
f063954
  	if (vim_is_ctrl_x_key(c) && c != Ctrl_X && c != Ctrl_R)
f063954
***************
f063954
*** 4319,4330 ****
f063954
  	    (void)ins_compl_next(FALSE, ins_compl_key2count(c),
f063954
  						    c != K_UP && c != K_DOWN);
f063954
  	}
f063954
! 	else if (c != Ctrl_R)
f063954
! 	    compl_interrupted = TRUE;
f063954
      }
f063954
      if (compl_pending != 0 && !got_int)
f063954
! 	(void)ins_compl_next(FALSE, compl_pending > 0
f063954
! 				      ? compl_pending : -compl_pending, TRUE);
f063954
  }
f063954
  
f063954
  /*
f063954
--- 4340,4366 ----
f063954
  	    (void)ins_compl_next(FALSE, ins_compl_key2count(c),
f063954
  						    c != K_UP && c != K_DOWN);
f063954
  	}
f063954
! 	else
f063954
! 	{
f063954
! 	    /* Need to get the character to have KeyTyped set.  We'll put it
f063954
! 	     * back with vungetc() below. */
f063954
! 	    c = safe_vgetc();
f063954
! 
f063954
! 	    /* Don't interrupt completion when the character wasn't typed,
f063954
! 	     * e.g., when doing @q to replay keys. */
f063954
! 	    if (c != Ctrl_R && KeyTyped)
f063954
! 		compl_interrupted = TRUE;
f063954
! 
f063954
! 	    vungetc(c);
f063954
! 	}
f063954
      }
f063954
      if (compl_pending != 0 && !got_int)
f063954
!     {
f063954
! 	int todo = compl_pending > 0 ? compl_pending : -compl_pending;
f063954
! 
f063954
! 	compl_pending = 0;
f063954
! 	(void)ins_compl_next(FALSE, todo, TRUE);
f063954
!     }
f063954
  }
f063954
  
f063954
  /*
f063954
*** ../vim-7.0.034/src/version.c	Fri Jun 23 17:59:26 2006
f063954
--- src/version.c	Fri Jun 23 21:35:39 2006
f063954
***************
f063954
*** 668,669 ****
f063954
--- 668,671 ----
f063954
  {   /* Add new patch number below this line */
f063954
+ /**/
f063954
+     35,
f063954
  /**/
f063954
f063954
-- 
f063954
So when I saw the post to comp.editors, I rushed over to the FTP site to
f063954
grab it.  So I yank apart the tarball, light x candles, where x= the
f063954
vim version multiplied by the md5sum of the source divided by the MAC of
f063954
my NIC (8A3FA78155A8A1D346C3C4A), put on black robes, dim the lights,
f063954
wave a dead chicken over the hard drive, and summon the power of GNU GCC
f063954
with the magic words "make config ; make!".
f063954
		[Jason Spence, compiling Vim 5.0]
f063954
f063954
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
f063954
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
f063954
\\\        download, build and distribute -- http://www.A-A-P.org        ///
f063954
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///