Karsten Hopp 042920
To: vim_dev@googlegroups.com
Karsten Hopp 042920
Subject: Patch 7.3.891
Karsten Hopp 042920
Fcc: outbox
Karsten Hopp 042920
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 042920
Mime-Version: 1.0
Karsten Hopp 042920
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 042920
Content-Transfer-Encoding: 8bit
Karsten Hopp 042920
------------
Karsten Hopp 042920
Karsten Hopp 042920
Patch 7.3.891
Karsten Hopp 042920
Problem:    Merging viminfo history doesn't work well.
Karsten Hopp 042920
Solution:   Don't stop when one type of history is empty. Don't merge history
Karsten Hopp 042920
	    when writing viminfo.
Karsten Hopp 042920
Files:	    src/ex_getln.c
Karsten Hopp 042920
Karsten Hopp 042920
Karsten Hopp 042920
*** ../vim-7.3.890/src/ex_getln.c	2013-04-06 14:28:56.000000000 +0200
Karsten Hopp 042920
--- src/ex_getln.c	2013-04-14 16:25:28.000000000 +0200
Karsten Hopp 042920
***************
Karsten Hopp 042920
*** 6130,6136 ****
Karsten Hopp 042920
      for (type = 0; type < HIST_COUNT; ++type)
Karsten Hopp 042920
      {
Karsten Hopp 042920
  	if (history[type] == NULL)
Karsten Hopp 042920
! 	    return;
Karsten Hopp 042920
  	idx = hisidx[type] + viminfo_hisidx[type];
Karsten Hopp 042920
  	if (idx >= hislen)
Karsten Hopp 042920
  	    idx -= hislen;
Karsten Hopp 042920
--- 6130,6136 ----
Karsten Hopp 042920
      for (type = 0; type < HIST_COUNT; ++type)
Karsten Hopp 042920
      {
Karsten Hopp 042920
  	if (history[type] == NULL)
Karsten Hopp 042920
! 	    continue;
Karsten Hopp 042920
  	idx = hisidx[type] + viminfo_hisidx[type];
Karsten Hopp 042920
  	if (idx >= hislen)
Karsten Hopp 042920
  	    idx -= hislen;
Karsten Hopp 042920
***************
Karsten Hopp 042920
*** 6182,6187 ****
Karsten Hopp 042920
--- 6182,6188 ----
Karsten Hopp 042920
      int	    num_saved;
Karsten Hopp 042920
      char_u  *p;
Karsten Hopp 042920
      int	    c;
Karsten Hopp 042920
+     int     round;
Karsten Hopp 042920
  
Karsten Hopp 042920
      init_history();
Karsten Hopp 042920
      if (hislen == 0)
Karsten Hopp 042920
***************
Karsten Hopp 042920
*** 6200,6225 ****
Karsten Hopp 042920
  					_("Input Line"));
Karsten Hopp 042920
  	if (num_saved > hislen)
Karsten Hopp 042920
  	    num_saved = hislen;
Karsten Hopp 042920
! 	i = hisidx[type];
Karsten Hopp 042920
! 	if (i >= 0)
Karsten Hopp 042920
! 	    while (num_saved--)
Karsten Hopp 042920
! 	    {
Karsten Hopp 042920
! 		p = history[type][i].hisstr;
Karsten Hopp 042920
! 		if (p != NULL)
Karsten Hopp 042920
  		{
Karsten Hopp 042920
! 		    fputc(hist_type2char(type, TRUE), fp);
Karsten Hopp 042920
! 		    /* For the search history: put the separator in the second
Karsten Hopp 042920
! 		     * column; use a space if there isn't one. */
Karsten Hopp 042920
! 		    if (type == HIST_SEARCH)
Karsten Hopp 042920
  		    {
Karsten Hopp 042920
! 			c = p[STRLEN(p) + 1];
Karsten Hopp 042920
! 			putc(c == NUL ? ' ' : c, fp);
Karsten Hopp 042920
  		    }
Karsten Hopp 042920
- 		    viminfo_writestring(fp, p);
Karsten Hopp 042920
  		}
Karsten Hopp 042920
! 		if (--i < 0)
Karsten Hopp 042920
! 		    i = hislen - 1;
Karsten Hopp 042920
! 	    }
Karsten Hopp 042920
      }
Karsten Hopp 042920
  }
Karsten Hopp 042920
  #endif /* FEAT_VIMINFO */
Karsten Hopp 042920
--- 6201,6250 ----
Karsten Hopp 042920
  					_("Input Line"));
Karsten Hopp 042920
  	if (num_saved > hislen)
Karsten Hopp 042920
  	    num_saved = hislen;
Karsten Hopp 042920
! 
Karsten Hopp 042920
! 	/*
Karsten Hopp 042920
! 	 * Merge typed and viminfo history:
Karsten Hopp 042920
! 	 * round 1: history of typed commands.
Karsten Hopp 042920
! 	 * round 2: history from recently read viminfo.
Karsten Hopp 042920
! 	 */
Karsten Hopp 042920
! 	for (round = 1; round <= 2; ++round)
Karsten Hopp 042920
! 	{
Karsten Hopp 042920
! 	    i = round == 1 ? hisidx[type] : 0;
Karsten Hopp 042920
! 	    if (i >= 0)
Karsten Hopp 042920
! 		while (num_saved > 0
Karsten Hopp 042920
! 			&& !(round == 2 && i >= viminfo_hisidx[type]))
Karsten Hopp 042920
  		{
Karsten Hopp 042920
! 		    p = round == 1 ? history[type][i].hisstr
Karsten Hopp 042920
! 						   : viminfo_history[type][i];
Karsten Hopp 042920
! 		    if (p != NULL)
Karsten Hopp 042920
  		    {
Karsten Hopp 042920
! 			--num_saved;
Karsten Hopp 042920
! 			fputc(hist_type2char(type, TRUE), fp);
Karsten Hopp 042920
! 			/* For the search history: put the separator in the
Karsten Hopp 042920
! 			 * second column; use a space if there isn't one. */
Karsten Hopp 042920
! 			if (type == HIST_SEARCH)
Karsten Hopp 042920
! 			{
Karsten Hopp 042920
! 			    c = p[STRLEN(p) + 1];
Karsten Hopp 042920
! 			    putc(c == NUL ? ' ' : c, fp);
Karsten Hopp 042920
! 			}
Karsten Hopp 042920
! 			viminfo_writestring(fp, p);
Karsten Hopp 042920
! 		    }
Karsten Hopp 042920
! 		    if (round == 1)
Karsten Hopp 042920
! 		    {
Karsten Hopp 042920
! 			/* Decrement index, loop around and stop when back at
Karsten Hopp 042920
! 			 * the start. */
Karsten Hopp 042920
! 			if (--i < 0)
Karsten Hopp 042920
! 			    i = hislen - 1;
Karsten Hopp 042920
! 			if (i == hisidx[type])
Karsten Hopp 042920
! 			    break;
Karsten Hopp 042920
! 		    }
Karsten Hopp 042920
! 		    else
Karsten Hopp 042920
! 		    {
Karsten Hopp 042920
! 			/* Increment index. Stop at the end in the while. */
Karsten Hopp 042920
! 			++i;
Karsten Hopp 042920
  		    }
Karsten Hopp 042920
  		}
Karsten Hopp 042920
! 	}
Karsten Hopp 042920
      }
Karsten Hopp 042920
  }
Karsten Hopp 042920
  #endif /* FEAT_VIMINFO */
Karsten Hopp 042920
*** ../vim-7.3.890/src/version.c	2013-04-14 16:21:30.000000000 +0200
Karsten Hopp 042920
--- src/version.c	2013-04-14 16:23:17.000000000 +0200
Karsten Hopp 042920
***************
Karsten Hopp 042920
*** 730,731 ****
Karsten Hopp 042920
--- 730,733 ----
Karsten Hopp 042920
  {   /* Add new patch number below this line */
Karsten Hopp 042920
+ /**/
Karsten Hopp 042920
+     891,
Karsten Hopp 042920
  /**/
Karsten Hopp 042920
Karsten Hopp 042920
-- 
Karsten Hopp 042920
"The question of whether computers can think is just like the question
Karsten Hopp 042920
of whether submarines can swim."      -- Edsger W. Dijkstra
Karsten Hopp 042920
Karsten Hopp 042920
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 042920
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 042920
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 042920
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///