summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <bram@vim.org>2013-06-15 16:31:47 +0200
committerBram Moolenaar <bram@vim.org>2013-06-15 16:31:47 +0200
commitb9dd2fc45f93792cb7713d5f71b994a94f9121dc (patch)
tree326d1063ab55dc7b43484a15c97c1f8f504042ca
parent304632e3c11d5cd0608f67735903c5e7b9983416 (diff)
downloadvim-b9dd2fc45f93792cb7713d5f71b994a94f9121dc.tar.gz
updated for version 7.3.1197v7.3.1197v7-3-1197
Problem: ":wviminfo!" does not write history previously read from a viminfo file. (Roland Eggner) Solution: When not merging history write all entries.
-rw-r--r--src/ex_cmds.c18
-rw-r--r--src/ex_getln.c16
-rw-r--r--src/proto/ex_getln.pro2
-rw-r--r--src/version.c2
4 files changed, 28 insertions, 10 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index a61bcdd3..445b66fe 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -1722,11 +1722,11 @@ read_viminfo(file, flags)
}
/*
- * write_viminfo() -- Write the viminfo file. The old one is read in first so
- * that effectively a merge of current info and old info is done. This allows
- * multiple vims to run simultaneously, without losing any marks etc. If
- * forceit is TRUE, then the old file is not read in, and only internal info is
- * written to the file. -- webb
+ * Write the viminfo file. The old one is read in first so that effectively a
+ * merge of current info and old info is done. This allows multiple vims to
+ * run simultaneously, without losing any marks etc.
+ * If "forceit" is TRUE, then the old file is not read in, and only internal
+ * info is written to the file.
*/
void
write_viminfo(file, forceit)
@@ -2047,6 +2047,7 @@ do_viminfo(fp_in, fp_out, flags)
int count = 0;
int eof = FALSE;
vir_T vir;
+ int merge = FALSE;
if ((vir.vir_line = alloc(LSIZE)) == NULL)
return;
@@ -2058,9 +2059,12 @@ do_viminfo(fp_in, fp_out, flags)
if (fp_in != NULL)
{
if (flags & VIF_WANT_INFO)
+ {
eof = read_viminfo_up_to_marks(&vir,
flags & VIF_FORCEIT, fp_out != NULL);
- else
+ merge = TRUE;
+ }
+ else if (flags != 0)
/* Skip info, find start of marks */
while (!(eof = viminfo_readline(&vir))
&& vir.vir_line[0] != '>')
@@ -2079,7 +2083,7 @@ do_viminfo(fp_in, fp_out, flags)
write_viminfo_search_pattern(fp_out);
write_viminfo_sub_string(fp_out);
#ifdef FEAT_CMDHIST
- write_viminfo_history(fp_out);
+ write_viminfo_history(fp_out, merge);
#endif
write_viminfo_registers(fp_out);
#ifdef FEAT_EVAL
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 4bebe230..e407ab0a 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -6003,6 +6003,9 @@ ex_history(eap)
#endif
#if (defined(FEAT_VIMINFO) && defined(FEAT_CMDHIST)) || defined(PROTO)
+/*
+ * Buffers for history read from a viminfo file. Only valid while reading.
+ */
static char_u **viminfo_history[HIST_COUNT] = {NULL, NULL, NULL, NULL};
static int viminfo_hisidx[HIST_COUNT] = {0, 0, 0, 0};
static int viminfo_hislen[HIST_COUNT] = {0, 0, 0, 0};
@@ -6184,9 +6187,16 @@ finish_viminfo_history()
}
}
+/*
+ * Write history to viminfo file in "fp".
+ * When "merge" is TRUE merge history lines with a previously read viminfo
+ * file, data is in viminfo_history[].
+ * When "merge" is FALSE just write all history lines. Used for ":wviminfo!".
+ */
void
-write_viminfo_history(fp)
+write_viminfo_history(fp, merge)
FILE *fp;
+ int merge;
{
int i;
int type;
@@ -6236,7 +6246,9 @@ write_viminfo_history(fp)
p = round == 1 ? history[type][i].hisstr
: viminfo_history[type] == NULL ? NULL
: viminfo_history[type][i];
- if (p != NULL && (round == 2 || !history[type][i].viminfo))
+ if (p != NULL && (round == 2
+ || !merge
+ || !history[type][i].viminfo))
{
--num_saved;
fputc(hist_type2char(type, TRUE), fp);
diff --git a/src/proto/ex_getln.pro b/src/proto/ex_getln.pro
index 9c2b5f6e..a8f960b1 100644
--- a/src/proto/ex_getln.pro
+++ b/src/proto/ex_getln.pro
@@ -51,7 +51,7 @@ void ex_history __ARGS((exarg_T *eap));
void prepare_viminfo_history __ARGS((int asklen, int writing));
int read_viminfo_history __ARGS((vir_T *virp, int writing));
void finish_viminfo_history __ARGS((void));
-void write_viminfo_history __ARGS((FILE *fp));
+void write_viminfo_history __ARGS((FILE *fp, int merge));
void cmd_pchar __ARGS((int c, int offset));
int cmd_gchar __ARGS((int offset));
char_u *script_get __ARGS((exarg_T *eap, char_u *cmd));
diff --git a/src/version.c b/src/version.c
index 8fa7aace..ca687c7f 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 */
/**/
+ 1197,
+/**/
1196,
/**/
1195,