1
0
forked from aniani/vim

updated for version 7.3.892

Problem:    Still mering problems for viminfo history.
Solution:   Do not merge lines when writing, don't write old viminfo lines.
This commit is contained in:
Bram Moolenaar
2013-04-14 23:19:36 +02:00
parent 6f852a557d
commit 07219f911c
4 changed files with 27 additions and 13 deletions

View File

@@ -2113,7 +2113,7 @@ read_viminfo_up_to_marks(virp, forceit, writing)
buf_T *buf; buf_T *buf;
#ifdef FEAT_CMDHIST #ifdef FEAT_CMDHIST
prepare_viminfo_history(forceit ? 9999 : 0); prepare_viminfo_history(forceit ? 9999 : 0, writing);
#endif #endif
eof = viminfo_readline(virp); eof = viminfo_readline(virp);
while (!eof && virp->vir_line[0] != '>') while (!eof && virp->vir_line[0] != '>')
@@ -2161,7 +2161,7 @@ read_viminfo_up_to_marks(virp, forceit, writing)
case '=': case '=':
case '@': case '@':
#ifdef FEAT_CMDHIST #ifdef FEAT_CMDHIST
eof = read_viminfo_history(virp); eof = read_viminfo_history(virp, writing);
#else #else
eof = viminfo_readline(virp); eof = viminfo_readline(virp);
#endif #endif
@@ -2182,7 +2182,8 @@ read_viminfo_up_to_marks(virp, forceit, writing)
#ifdef FEAT_CMDHIST #ifdef FEAT_CMDHIST
/* Finish reading history items. */ /* Finish reading history items. */
finish_viminfo_history(); if (!writing)
finish_viminfo_history();
#endif #endif
/* Change file names to buffer numbers for fmarks. */ /* Change file names to buffer numbers for fmarks. */

View File

@@ -68,7 +68,7 @@ static int hislen = 0; /* actual length of history tables */
static int hist_char2type __ARGS((int c)); static int hist_char2type __ARGS((int c));
static int in_history __ARGS((int, char_u *, int, int)); static int in_history __ARGS((int, char_u *, int, int, int));
# ifdef FEAT_EVAL # ifdef FEAT_EVAL
static int calc_hist_idx __ARGS((int histype, int num)); static int calc_hist_idx __ARGS((int histype, int num));
# endif # endif
@@ -5397,11 +5397,12 @@ clear_hist_entry(hisptr)
* If 'move_to_front' is TRUE, matching entry is moved to end of history. * If 'move_to_front' is TRUE, matching entry is moved to end of history.
*/ */
static int static int
in_history(type, str, move_to_front, sep) in_history(type, str, move_to_front, sep, writing)
int type; int type;
char_u *str; char_u *str;
int move_to_front; /* Move the entry to the front if it exists */ int move_to_front; /* Move the entry to the front if it exists */
int sep; int sep;
int writing; /* ignore entries read from viminfo */
{ {
int i; int i;
int last_i = -1; int last_i = -1;
@@ -5419,6 +5420,7 @@ in_history(type, str, move_to_front, sep)
* well. */ * well. */
p = history[type][i].hisstr; p = history[type][i].hisstr;
if (STRCMP(str, p) == 0 if (STRCMP(str, p) == 0
&& !(writing && history[type][i].viminfo)
&& (type != HIST_SEARCH || sep == p[STRLEN(p) + 1])) && (type != HIST_SEARCH || sep == p[STRLEN(p) + 1]))
{ {
if (!move_to_front) if (!move_to_front)
@@ -5513,7 +5515,7 @@ add_to_history(histype, new_entry, in_map, sep)
} }
last_maptick = -1; last_maptick = -1;
} }
if (!in_history(histype, new_entry, TRUE, sep)) if (!in_history(histype, new_entry, TRUE, sep, FALSE))
{ {
if (++hisidx[histype] == hislen) if (++hisidx[histype] == hislen)
hisidx[histype] = 0; hisidx[histype] = 0;
@@ -6032,8 +6034,9 @@ hist_type2char(type, use_question)
* This allocates history arrays to store the read history lines. * This allocates history arrays to store the read history lines.
*/ */
void void
prepare_viminfo_history(asklen) prepare_viminfo_history(asklen, writing)
int asklen; int asklen;
int writing;
{ {
int i; int i;
int num; int num;
@@ -6041,7 +6044,7 @@ prepare_viminfo_history(asklen)
int len; int len;
init_history(); init_history();
viminfo_add_at_front = (asklen != 0); viminfo_add_at_front = (asklen != 0 && !writing);
if (asklen > hislen) if (asklen > hislen)
asklen = hislen; asklen = hislen;
@@ -6073,8 +6076,9 @@ prepare_viminfo_history(asklen)
* new. * new.
*/ */
int int
read_viminfo_history(virp) read_viminfo_history(virp, writing)
vir_T *virp; vir_T *virp;
int writing;
{ {
int type; int type;
long_u len; long_u len;
@@ -6090,7 +6094,7 @@ read_viminfo_history(virp)
int sep = (*val == ' ' ? NUL : *val); int sep = (*val == ' ' ? NUL : *val);
if (!in_history(type, val + (type == HIST_SEARCH), if (!in_history(type, val + (type == HIST_SEARCH),
viminfo_add_at_front, sep)) viminfo_add_at_front, sep, writing))
{ {
/* Need to re-allocate to append the separator byte. */ /* Need to re-allocate to append the separator byte. */
len = STRLEN(val); len = STRLEN(val);
@@ -6120,6 +6124,9 @@ read_viminfo_history(virp)
return viminfo_readline(virp); return viminfo_readline(virp);
} }
/*
* Finish reading history lines from viminfo. Not used when writing viminfo.
*/
void void
finish_viminfo_history() finish_viminfo_history()
{ {
@@ -6216,7 +6223,7 @@ write_viminfo_history(fp)
{ {
p = round == 1 ? history[type][i].hisstr p = round == 1 ? history[type][i].hisstr
: viminfo_history[type][i]; : viminfo_history[type][i];
if (p != NULL) if (p != NULL && (round == 2 || !history[type][i].viminfo))
{ {
--num_saved; --num_saved;
fputc(hist_type2char(type, TRUE), fp); fputc(hist_type2char(type, TRUE), fp);
@@ -6245,6 +6252,10 @@ write_viminfo_history(fp)
} }
} }
} }
for (i = 0; i < viminfo_hisidx[type]; ++i)
vim_free(viminfo_history[type][i]);
vim_free(viminfo_history[type]);
viminfo_history[type] = NULL;
} }
} }
#endif /* FEAT_VIMINFO */ #endif /* FEAT_VIMINFO */

View File

@@ -48,8 +48,8 @@ int del_history_idx __ARGS((int histype, int idx));
void remove_key_from_history __ARGS((void)); void remove_key_from_history __ARGS((void));
int get_list_range __ARGS((char_u **str, int *num1, int *num2)); int get_list_range __ARGS((char_u **str, int *num1, int *num2));
void ex_history __ARGS((exarg_T *eap)); void ex_history __ARGS((exarg_T *eap));
void prepare_viminfo_history __ARGS((int asklen)); void prepare_viminfo_history __ARGS((int asklen, int writing));
int read_viminfo_history __ARGS((vir_T *virp)); int read_viminfo_history __ARGS((vir_T *virp, int writing));
void finish_viminfo_history __ARGS((void)); void finish_viminfo_history __ARGS((void));
void write_viminfo_history __ARGS((FILE *fp)); void write_viminfo_history __ARGS((FILE *fp));
void cmd_pchar __ARGS((int c, int offset)); void cmd_pchar __ARGS((int c, int offset));

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 */
/**/
892,
/**/ /**/
891, 891,
/**/ /**/