The attached patch fixes the behaviour of Vim where histadd() and
searching with * fail to add elements to history if the history is
empty.

How to reproduce:

Problem with histadd():

$ vim -i NONE -c 'call histadd("search", "search")' \
              -c 'call histadd("search", "for")'    \
              -c 'call histadd("search", "some")'   \
              -c 'call histadd("search", "words")'  \
              -c 'call feedkeys("q/")'

Problem with searching with *:

vim -i NONE -c 'normal ido'        \
            -c 'normal osome'      \
            -c 'normal osearching' \
            -c 'normal oplease'    \
            -c 'normal gg'         \
            -c 'normal *'          \
            -c 'call feedkeys("q/")'

Note that the window containing the history is empty, although it should
contain 4 elements in the first case and 1 element in the second case.

-- 
Cheers,
Lech

-- 
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
diff --git a/src/eval.c b/src/eval.c
index 9f70467..0ce6ff1 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -12014,6 +12014,7 @@ f_histadd(argvars, rettv)
 	str = get_tv_string_buf(&argvars[1], buf);
 	if (*str != NUL)
 	{
+	    init_history();
 	    add_to_history(histype, str, FALSE, NUL);
 	    rettv->vval.v_number = TRUE;
 	    return;
diff --git a/src/normal.c b/src/normal.c
index 160beb6..befe4ac 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -5602,6 +5602,7 @@ nv_ident(cap)
 	    STRCAT(buf, "\\>");
 #ifdef FEAT_CMDHIST
 	/* put pattern in search history */
+	init_history();
 	add_to_history(HIST_SEARCH, buf, TRUE, NUL);
 #endif
 	normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0);

Raspunde prin e-mail lui