From 26b654a5df9414e43734eb4c956b67c331d70a50 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 22 Jul 2019 20:50:17 +0200 Subject: patch 8.1.1731: command line history not read from viminfo on startup Problem: Command line history not read from viminfo on startup. Solution: Get history length after initializing it. --- src/testdir/test_viminfo.vim | 6 ++++++ src/version.c | 2 ++ src/viminfo.c | 5 +++-- 3 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/testdir/test_viminfo.vim b/src/testdir/test_viminfo.vim index cea78e574..8206458d9 100644 --- a/src/testdir/test_viminfo.vim +++ b/src/testdir/test_viminfo.vim @@ -1,6 +1,12 @@ " Test for reading and writing .viminfo function Test_viminfo_read_and_write() + " First clear 'history', so that "hislen" is zero. Then set it again, + " simulating Vim starting up. + set history=0 + wviminfo Xviminfo + set history=1000 + call histdel(':') let lines = [ \ '# comment line', diff --git a/src/version.c b/src/version.c index 69baf5439..d8b3dfedb 100644 --- a/src/version.c +++ b/src/version.c @@ -777,6 +777,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1731, /**/ 1730, /**/ diff --git a/src/viminfo.c b/src/viminfo.c index 888014446..7e192cecd 100644 --- a/src/viminfo.c +++ b/src/viminfo.c @@ -212,9 +212,10 @@ prepare_viminfo_history(int asklen, int writing) int num; int type; int len; - int hislen = get_hislen(); + int hislen; init_history(); + hislen = get_hislen(); viminfo_add_at_front = (asklen != 0 && !writing); if (asklen > hislen) asklen = hislen; @@ -460,7 +461,7 @@ merge_history(int type) // Make one long list with all entries. max_len = hislen + viminfo_hisidx[type]; tot_hist = ALLOC_MULT(histentry_T *, max_len); - new_hist = ALLOC_MULT(histentry_T, hislen ); + new_hist = ALLOC_MULT(histentry_T, hislen); if (tot_hist == NULL || new_hist == NULL) { vim_free(tot_hist); -- cgit v1.2.1