On 2013-06-05 Wednesday at 12:43 +0200 Bram Moolenaar wrote:
> Roland Eggner wrote:
> > After update 7.3.{865,969} I notice this regression:
> > “:wviminfo! filename” writes only new history entries, misses old
> > entries read by “:rviminfo! filename”. “:history” shows old and new
> > entries properly, apart from the fact, that entries from viminfo
> > versions older than the previous one are missing (even far below the
> > history limit). This renders the viminfo-feature almost useless for
> > my needs, I will go back to 7.3.865.
> >
> > I tried to create minimalistic steps for reproduction of the problem
> > and found another error: When starting with empty history and not
> > using “:rviminfo”, then history seems to remain empty for ever, and
> > “:history” fails with a surprising
> > error message:
> >
> > LC_MESSAGES=C vim -u NONE -c ':set nocompatible history=20' \
> > -c ':echo "first history entry"' \
> > -c ':set viminfo? history?' \
> > -c ':history' \
> > -c ':wviminfo! test.viminfo' \
> > -c ':q'
> > --------------------------------------
> > first history entry
> > viminfo='100,<50,s10,h
> > history=20
> > 'history' option is zero
>
> [...]
>
> > Just in case “-u NONE” disables history, I tried the following commandline
> > and
> > got the same result:
> > LC_MESSAGES=C vim -u /dev/null -i test.viminfo --noplugin \
> > -c ':set nocompatible history=20' \
> > -c ':echo "first"' \
> > -c ':set viminfo? history?' \
> > -c ':history' \
> > -c ':wviminfo! test.viminfo' \
> > -c ':q'
> >
> >
> > Even repeating above vim commandline after inserting a history entry with
> > following sed command yields the very same result:
> > sed -i -e '/Command Line History/a :echo "inserted by sed"' test.viminfo
> >
> [...]
>
> Thanks for reporting clearly. I'll add this in the todo list.
Thanks.> It's probably a matter of writing old entries when not reading back from > an existing viminfo file. I reported not clearly enough, I am afraid. There are 2 probably related bugs: (1) Commit “7.3.880 Problem: When writing viminfo, old history lines may replace lines written more recently by another Vim instance. Solution: Mark history entries that were read from viminfo and overwrite them when merging with the current viminfo.” turned the viminfo feature effectively to a “vimforget” feature. The patch provided below reverts this. vim-7.3.969 with this patch applied passes “make test” in my environments, and so far does what I want (my viminfo files are tracked by mercurial; after a few vim sessions I checked them and found everything ok). I tried to make the patch as small as possible, so interested users can apply it with low risk of conflicts with future commits as long as the issue remains on the todo list. For this reason the patch does not revert commit 7.3.880 completely, rather it leaves behind some redundant code. On my systems vim is usually called by a wrapper script which sets some environment variables and writes a lockfile corresponding to the presumably used viminfo file. Controlled by this environment variables “/etc/vim/vimrc” … • sets for each parent command (bash, mutt, mc, hg, less …) and for each $PWD another viminfo file, • executes “:rviminfo!” and • defines “BufWritePost” and “VimLeavePre” autocommands containing “:wviminfo!”. Thus my viminfo files are never used by more than one vim instance, and I have no need for the merging capability of :[rw]viminfo. Merging would lead to frequent loss of history entries I have learned many years ago when I started to use vim for every file editing work. (2) ex-commands in arguments to commandline options -c and --cmd do not enter the command history. Even after “-c ':set nocompatible history 20'” and “-c ':set compatible? history?'” reporting the expected settings, the command history remains empty and on “-c ':history'” vim complains “'history' option is zero”. How gets history value implicitely turned from 20 to zero? -- Regards Roland Eggner
diff --git a/src/ex_getln.c b/src/ex_getln.c
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -6050,9 +6050,13 @@ prepare_viminfo_history(asklen, writing)
for (type = 0; type < HIST_COUNT; ++type)
{
- /* Count the number of empty spaces in the history list. Entries read
- * from viminfo previously are also considered empty. If there are
- * more spaces available than we request, then fill them up. */
+ /* Count the number of empty spaces in the history list.
+ * Entries read from viminfo file were also considered empty since
+ * v7.3.880; this particular change is reverted by this patch. We
want
+ * oldest history entries being dropped for no other reason than
+ * exceeding the history length limit set by option history.
+ * If there are more spaces available than we request, then fill them
+ * up. */
for (i = 0, num = 0; i < hislen; i++)
if (history[type][i].hisstr == NULL || history[type][i].viminfo)
num++;
@@ -6164,7 +6168,7 @@ finish_viminfo_history()
{
vim_free(history[type][idx].hisstr);
history[type][idx].hisstr = viminfo_history[type][i];
- history[type][idx].viminfo = TRUE;
+ history[type][idx].viminfo = FALSE;
if (--idx < 0)
idx = hislen - 1;
}
pgp17JX5L55zf.pgp
Description: PGP signature
