*** ex_getln.c.orig	2011-07-20 22:35:22.540320700 +0900
--- ex_getln.c	2011-07-20 22:48:04.029204400 +0900
***************
*** 67,73 ****
  
  static int	hist_char2type __ARGS((int c));
  
! static int	in_history __ARGS((int, char_u *, int));
  # ifdef FEAT_EVAL
  static int	calc_hist_idx __ARGS((int histype, int num));
  # endif
--- 67,73 ----
  
  static int	hist_char2type __ARGS((int c));
  
! static int	in_history __ARGS((int, char_u *, int, int));
  # ifdef FEAT_EVAL
  static int	calc_hist_idx __ARGS((int histype, int num));
  # endif
***************
*** 5306,5315 ****
   * If 'move_to_front' is TRUE, matching entry is moved to end of history.
   */
      static int
! in_history(type, str, move_to_front)
      int	    type;
      char_u  *str;
      int	    move_to_front;	/* Move the entry to the front if it exists */
  {
      int	    i;
      int	    last_i = -1;
--- 5306,5316 ----
   * If 'move_to_front' is TRUE, matching entry is moved to end of history.
   */
      static int
! in_history(type, str, move_to_front, sep)
      int	    type;
      char_u  *str;
      int	    move_to_front;	/* Move the entry to the front if it exists */
+     int	    sep;
  {
      int	    i;
      int	    last_i = -1;
***************
*** 5323,5328 ****
--- 5324,5336 ----
  	    return FALSE;
  	if (STRCMP(str, history[type][i].hisstr) == 0)
  	{
+ 	    char_u *p = history[type][i].hisstr;
+ 
+ 	    /* For search history, equation check includes first characters
+ 	     * equation. */
+ 	    if (type == HIST_SEARCH && sep != p[STRLEN(p) + 1])
+ 		break;
+ 
  	    if (!move_to_front)
  		return TRUE;
  	    last_i = i;
***************
*** 5415,5421 ****
  	}
  	last_maptick = -1;
      }
!     if (!in_history(histype, new_entry, TRUE))
      {
  	if (++hisidx[histype] == hislen)
  	    hisidx[histype] = 0;
--- 5423,5429 ----
  	}
  	last_maptick = -1;
      }
!     if (!in_history(histype, new_entry, TRUE, sep))
      {
  	if (++hisidx[histype] == hislen)
  	    hisidx[histype] = 0;
***************
*** 5994,6000 ****
  	if (val != NULL && *val != NUL)
  	{
  	    if (!in_history(type, val + (type == HIST_SEARCH),
! 							viminfo_add_at_front))
  	    {
  		/* Need to re-allocate to append the separator byte. */
  		len = STRLEN(val);
--- 6002,6008 ----
  	if (val != NULL && *val != NUL)
  	{
  	    if (!in_history(type, val + (type == HIST_SEARCH),
! 			viminfo_add_at_front, *val))
  	    {
  		/* Need to re-allocate to append the separator byte. */
  		len = STRLEN(val);
