0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

updated for version 7.3.891

Problem:    Merging viminfo history doesn't work well.
Solution:   Don't stop when one type of history is empty. Don't merge history
            when writing viminfo.
This commit is contained in:
Bram Moolenaar
2013-04-14 16:26:15 +02:00
parent 7311c6932c
commit 6f852a557d
2 changed files with 44 additions and 17 deletions

View File

@@ -6130,7 +6130,7 @@ finish_viminfo_history()
for (type = 0; type < HIST_COUNT; ++type) for (type = 0; type < HIST_COUNT; ++type)
{ {
if (history[type] == NULL) if (history[type] == NULL)
return; continue;
idx = hisidx[type] + viminfo_hisidx[type]; idx = hisidx[type] + viminfo_hisidx[type];
if (idx >= hislen) if (idx >= hislen)
idx -= hislen; idx -= hislen;
@@ -6182,6 +6182,7 @@ write_viminfo_history(fp)
int num_saved; int num_saved;
char_u *p; char_u *p;
int c; int c;
int round;
init_history(); init_history();
if (hislen == 0) if (hislen == 0)
@@ -6200,16 +6201,27 @@ write_viminfo_history(fp)
_("Input Line")); _("Input Line"));
if (num_saved > hislen) if (num_saved > hislen)
num_saved = hislen; num_saved = hislen;
i = hisidx[type];
if (i >= 0) /*
while (num_saved--) * Merge typed and viminfo history:
* round 1: history of typed commands.
* round 2: history from recently read viminfo.
*/
for (round = 1; round <= 2; ++round)
{ {
p = history[type][i].hisstr; i = round == 1 ? hisidx[type] : 0;
if (i >= 0)
while (num_saved > 0
&& !(round == 2 && i >= viminfo_hisidx[type]))
{
p = round == 1 ? history[type][i].hisstr
: viminfo_history[type][i];
if (p != NULL) if (p != NULL)
{ {
--num_saved;
fputc(hist_type2char(type, TRUE), fp); fputc(hist_type2char(type, TRUE), fp);
/* For the search history: put the separator in the second /* For the search history: put the separator in the
* column; use a space if there isn't one. */ * second column; use a space if there isn't one. */
if (type == HIST_SEARCH) if (type == HIST_SEARCH)
{ {
c = p[STRLEN(p) + 1]; c = p[STRLEN(p) + 1];
@@ -6217,8 +6229,21 @@ write_viminfo_history(fp)
} }
viminfo_writestring(fp, p); viminfo_writestring(fp, p);
} }
if (round == 1)
{
/* Decrement index, loop around and stop when back at
* the start. */
if (--i < 0) if (--i < 0)
i = hislen - 1; i = hislen - 1;
if (i == hisidx[type])
break;
}
else
{
/* Increment index. Stop at the end in the while. */
++i;
}
}
} }
} }
} }

View File

@@ -728,6 +728,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
891,
/**/ /**/
890, 890,
/**/ /**/