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