Karsten Hopp 968b18
To: vim-dev@vim.org
Karsten Hopp 968b18
Subject: Patch 7.0.023
Karsten Hopp 968b18
Fcc: outbox
Karsten Hopp 968b18
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 968b18
Mime-Version: 1.0
Karsten Hopp 968b18
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 968b18
Content-Transfer-Encoding: 8bit
Karsten Hopp 968b18
------------
Karsten Hopp 968b18
Karsten Hopp 968b18
Patch 7.0.023
Karsten Hopp 968b18
Problem:    Crash when doing spell completion in an empty line and pressing
Karsten Hopp 968b18
	    CTRL-E.
Karsten Hopp 968b18
Solution:   Check for a zero pointer. (James Vega)
Karsten Hopp 968b18
	    Also handle a situation without a matching pattern better, report
Karsten Hopp 968b18
	    "No matches" instead of remaining in undefined CTRL-X mode.  And
Karsten Hopp 968b18
	    get out of CTRL-X mode when typing a letter.
Karsten Hopp 968b18
Files:	    src/edit.c
Karsten Hopp 968b18
Karsten Hopp 968b18
Karsten Hopp 968b18
*** ../vim-7.0.022/src/edit.c	Sat May 13 15:27:57 2006
Karsten Hopp 968b18
--- src/edit.c	Thu Jun 22 16:44:01 2006
Karsten Hopp 968b18
***************
Karsten Hopp 968b18
*** 719,727 ****
Karsten Hopp 968b18
  #ifdef FEAT_INS_EXPAND
Karsten Hopp 968b18
  	/*
Karsten Hopp 968b18
  	 * Special handling of keys while the popup menu is visible or wanted
Karsten Hopp 968b18
! 	 * and the cursor is still in the completed word.
Karsten Hopp 968b18
  	 */
Karsten Hopp 968b18
! 	if (compl_started && pum_wanted() && curwin->w_cursor.col >= compl_col)
Karsten Hopp 968b18
  	{
Karsten Hopp 968b18
  	    /* BS: Delete one character from "compl_leader". */
Karsten Hopp 968b18
  	    if ((c == K_BS || c == Ctrl_H)
Karsten Hopp 968b18
--- 721,734 ----
Karsten Hopp 968b18
  #ifdef FEAT_INS_EXPAND
Karsten Hopp 968b18
  	/*
Karsten Hopp 968b18
  	 * Special handling of keys while the popup menu is visible or wanted
Karsten Hopp 968b18
! 	 * and the cursor is still in the completed word.  Only when there is
Karsten Hopp 968b18
! 	 * a match, skip this when no matches were found.
Karsten Hopp 968b18
  	 */
Karsten Hopp 968b18
! 	if (compl_started
Karsten Hopp 968b18
! 		&& pum_wanted()
Karsten Hopp 968b18
! 		&& curwin->w_cursor.col >= compl_col
Karsten Hopp 968b18
! 		&& (compl_shown_match == NULL
Karsten Hopp 968b18
! 		    || compl_shown_match != compl_shown_match->cp_next))
Karsten Hopp 968b18
  	{
Karsten Hopp 968b18
  	    /* BS: Delete one character from "compl_leader". */
Karsten Hopp 968b18
  	    if ((c == K_BS || c == Ctrl_H)
Karsten Hopp 968b18
***************
Karsten Hopp 968b18
*** 3393,3408 ****
Karsten Hopp 968b18
  		    ptr = compl_leader;
Karsten Hopp 968b18
  		else
Karsten Hopp 968b18
  		    ptr = compl_orig_text;
Karsten Hopp 968b18
! 		p = compl_orig_text;
Karsten Hopp 968b18
! 		for (temp = 0; p[temp] != NUL && p[temp] == ptr[temp]; ++temp)
Karsten Hopp 968b18
! 		    ;
Karsten Hopp 968b18
  #ifdef FEAT_MBYTE
Karsten Hopp 968b18
! 		if (temp > 0)
Karsten Hopp 968b18
! 		    temp -= (*mb_head_off)(compl_orig_text, p + temp);
Karsten Hopp 968b18
  #endif
Karsten Hopp 968b18
! 		for (p += temp; *p != NUL; mb_ptr_adv(p))
Karsten Hopp 968b18
! 		    AppendCharToRedobuff(K_BS);
Karsten Hopp 968b18
! 		AppendToRedobuffLit(ptr + temp, -1);
Karsten Hopp 968b18
  	    }
Karsten Hopp 968b18
  
Karsten Hopp 968b18
  #ifdef FEAT_CINDENT
Karsten Hopp 968b18
--- 3401,3421 ----
Karsten Hopp 968b18
  		    ptr = compl_leader;
Karsten Hopp 968b18
  		else
Karsten Hopp 968b18
  		    ptr = compl_orig_text;
Karsten Hopp 968b18
! 		if (compl_orig_text != NULL)
Karsten Hopp 968b18
! 		{
Karsten Hopp 968b18
! 		    p = compl_orig_text;
Karsten Hopp 968b18
! 		    for (temp = 0; p[temp] != NUL && p[temp] == ptr[temp];
Karsten Hopp 968b18
! 								       ++temp)
Karsten Hopp 968b18
! 			;
Karsten Hopp 968b18
  #ifdef FEAT_MBYTE
Karsten Hopp 968b18
! 		    if (temp > 0)
Karsten Hopp 968b18
! 			temp -= (*mb_head_off)(compl_orig_text, p + temp);
Karsten Hopp 968b18
  #endif
Karsten Hopp 968b18
! 		    for (p += temp; *p != NUL; mb_ptr_adv(p))
Karsten Hopp 968b18
! 			AppendCharToRedobuff(K_BS);
Karsten Hopp 968b18
! 		}
Karsten Hopp 968b18
! 		if (ptr != NULL)
Karsten Hopp 968b18
! 		    AppendToRedobuffLit(ptr + temp, -1);
Karsten Hopp 968b18
  	    }
Karsten Hopp 968b18
  
Karsten Hopp 968b18
  #ifdef FEAT_CINDENT
Karsten Hopp 968b18
***************
Karsten Hopp 968b18
*** 4650,4659 ****
Karsten Hopp 968b18
  				     (int)STRLEN(compl_pattern), curs_col);
Karsten Hopp 968b18
  	    if (compl_xp.xp_context == EXPAND_UNSUCCESSFUL
Karsten Hopp 968b18
  		    || compl_xp.xp_context == EXPAND_NOTHING)
Karsten Hopp 968b18
! 		return FAIL;
Karsten Hopp 968b18
! 	    startcol = (int)(compl_xp.xp_pattern - compl_pattern);
Karsten Hopp 968b18
! 	    compl_col = startcol;
Karsten Hopp 968b18
! 	    compl_length = curs_col - startcol;
Karsten Hopp 968b18
  	}
Karsten Hopp 968b18
  	else if (ctrl_x_mode == CTRL_X_FUNCTION || ctrl_x_mode == CTRL_X_OMNI)
Karsten Hopp 968b18
  	{
Karsten Hopp 968b18
--- 4663,4680 ----
Karsten Hopp 968b18
  				     (int)STRLEN(compl_pattern), curs_col);
Karsten Hopp 968b18
  	    if (compl_xp.xp_context == EXPAND_UNSUCCESSFUL
Karsten Hopp 968b18
  		    || compl_xp.xp_context == EXPAND_NOTHING)
Karsten Hopp 968b18
! 	    {
Karsten Hopp 968b18
! 		compl_col = curs_col;
Karsten Hopp 968b18
! 		compl_length = 0;
Karsten Hopp 968b18
! 		vim_free(compl_pattern);
Karsten Hopp 968b18
! 		compl_pattern = NULL;
Karsten Hopp 968b18
! 	    }
Karsten Hopp 968b18
! 	    else
Karsten Hopp 968b18
! 	    {
Karsten Hopp 968b18
! 		startcol = (int)(compl_xp.xp_pattern - compl_pattern);
Karsten Hopp 968b18
! 		compl_col = startcol;
Karsten Hopp 968b18
! 		compl_length = curs_col - startcol;
Karsten Hopp 968b18
! 	    }
Karsten Hopp 968b18
  	}
Karsten Hopp 968b18
  	else if (ctrl_x_mode == CTRL_X_FUNCTION || ctrl_x_mode == CTRL_X_OMNI)
Karsten Hopp 968b18
  	{
Karsten Hopp 968b18
***************
Karsten Hopp 968b18
*** 4707,4717 ****
Karsten Hopp 968b18
  	    else
Karsten Hopp 968b18
  		compl_col = spell_word_start(startcol);
Karsten Hopp 968b18
  	    if (compl_col >= (colnr_T)startcol)
Karsten Hopp 968b18
! 		return FAIL;
Karsten Hopp 968b18
! 	    spell_expand_check_cap(compl_col);
Karsten Hopp 968b18
  	    /* Need to obtain "line" again, it may have become invalid. */
Karsten Hopp 968b18
  	    line = ml_get(curwin->w_cursor.lnum);
Karsten Hopp 968b18
- 	    compl_length = (int)curs_col - compl_col;
Karsten Hopp 968b18
  	    compl_pattern = vim_strnsave(line + compl_col, compl_length);
Karsten Hopp 968b18
  	    if (compl_pattern == NULL)
Karsten Hopp 968b18
  #endif
Karsten Hopp 968b18
--- 4728,4744 ----
Karsten Hopp 968b18
  	    else
Karsten Hopp 968b18
  		compl_col = spell_word_start(startcol);
Karsten Hopp 968b18
  	    if (compl_col >= (colnr_T)startcol)
Karsten Hopp 968b18
! 	    {
Karsten Hopp 968b18
! 		compl_length = 0;
Karsten Hopp 968b18
! 		compl_col = curs_col;
Karsten Hopp 968b18
! 	    }
Karsten Hopp 968b18
! 	    else
Karsten Hopp 968b18
! 	    {
Karsten Hopp 968b18
! 		spell_expand_check_cap(compl_col);
Karsten Hopp 968b18
! 		compl_length = (int)curs_col - compl_col;
Karsten Hopp 968b18
! 	    }
Karsten Hopp 968b18
  	    /* Need to obtain "line" again, it may have become invalid. */
Karsten Hopp 968b18
  	    line = ml_get(curwin->w_cursor.lnum);
Karsten Hopp 968b18
  	    compl_pattern = vim_strnsave(line + compl_col, compl_length);
Karsten Hopp 968b18
  	    if (compl_pattern == NULL)
Karsten Hopp 968b18
  #endif
Karsten Hopp 968b18
*** ../vim-7.0.022/src/version.c	Tue Jun 20 21:08:02 2006
Karsten Hopp 968b18
--- src/version.c	Thu Jun 22 16:34:42 2006
Karsten Hopp 968b18
***************
Karsten Hopp 968b18
*** 668,669 ****
Karsten Hopp 968b18
--- 668,671 ----
Karsten Hopp 968b18
  {   /* Add new patch number below this line */
Karsten Hopp 968b18
+ /**/
Karsten Hopp 968b18
+     23,
Karsten Hopp 968b18
  /**/
Karsten Hopp 968b18
Karsten Hopp 968b18
-- 
Karsten Hopp 968b18
BEDEVERE: Look!  It's the old man from scene 24 - what's he Doing here?
Karsten Hopp 968b18
ARTHUR:   He is the keeper of the Bridge.  He asks each traveler five
Karsten Hopp 968b18
          questions ...
Karsten Hopp 968b18
GALAHAD:  Three questions.
Karsten Hopp 968b18
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
Karsten Hopp 968b18
Karsten Hopp 968b18
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 968b18
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 968b18
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 968b18
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///