summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <bram@vim.org>2013-04-14 16:26:15 +0200
committerBram Moolenaar <bram@vim.org>2013-04-14 16:26:15 +0200
commit61ac8622b6f0fae43dd6b51c1edce69db719493e (patch)
treee4dfa4042a777e62f7327966f97f9881496c9f64
parent63141e5f6f2f85452764a0edb2d6d6922e70f7f6 (diff)
downloadvim-61ac8622b6f0fae43dd6b51c1edce69db719493e.tar.gz
updated for version 7.3.891v7.3.891v7-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.
-rw-r--r--src/ex_getln.c59
-rw-r--r--src/version.c2
2 files changed, 44 insertions, 17 deletions
diff --git a/src/ex_getln.c b/src/ex_getln.c
index f3c36445..1faadd6c 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -6130,7 +6130,7 @@ finish_viminfo_history()
for (type = 0; type < HIST_COUNT; ++type)
{
if (history[type] == NULL)
- return;
+ continue;
idx = hisidx[type] + viminfo_hisidx[type];
if (idx >= hislen)
idx -= hislen;
@@ -6182,6 +6182,7 @@ write_viminfo_history(fp)
int num_saved;
char_u *p;
int c;
+ int round;
init_history();
if (hislen == 0)
@@ -6200,26 +6201,50 @@ write_viminfo_history(fp)
_("Input Line"));
if (num_saved > hislen)
num_saved = hislen;
- i = hisidx[type];
- if (i >= 0)
- while (num_saved--)
- {
- p = history[type][i].hisstr;
- if (p != NULL)
+
+ /*
+ * Merge typed and viminfo history:
+ * round 1: history of typed commands.
+ * round 2: history from recently read viminfo.
+ */
+ for (round = 1; round <= 2; ++round)
+ {
+ i = round == 1 ? hisidx[type] : 0;
+ if (i >= 0)
+ while (num_saved > 0
+ && !(round == 2 && i >= viminfo_hisidx[type]))
{
- fputc(hist_type2char(type, TRUE), fp);
- /* For the search history: put the separator in the second
- * column; use a space if there isn't one. */
- if (type == HIST_SEARCH)
+ p = round == 1 ? history[type][i].hisstr
+ : viminfo_history[type][i];
+ if (p != NULL)
{
- c = p[STRLEN(p) + 1];
- putc(c == NUL ? ' ' : c, fp);
+ --num_saved;
+ fputc(hist_type2char(type, TRUE), fp);
+ /* For the search history: put the separator in the
+ * second column; use a space if there isn't one. */
+ if (type == HIST_SEARCH)
+ {
+ c = p[STRLEN(p) + 1];
+ putc(c == NUL ? ' ' : c, fp);
+ }
+ viminfo_writestring(fp, p);
+ }
+ if (round == 1)
+ {
+ /* Decrement index, loop around and stop when back at
+ * the start. */
+ if (--i < 0)
+ i = hislen - 1;
+ if (i == hisidx[type])
+ break;
+ }
+ else
+ {
+ /* Increment index. Stop at the end in the while. */
+ ++i;
}
- viminfo_writestring(fp, p);
}
- if (--i < 0)
- i = hislen - 1;
- }
+ }
}
}
#endif /* FEAT_VIMINFO */
diff --git a/src/version.c b/src/version.c
index 197940ed..75cbcdb0 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 891,
+/**/
890,
/**/
889,