]> granicus.if.org Git - vim/commitdiff
patch 8.1.1731: command line history not read from viminfo on startup v8.1.1731
authorBram Moolenaar <Bram@vim.org>
Mon, 22 Jul 2019 18:50:17 +0000 (20:50 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 22 Jul 2019 18:50:17 +0000 (20:50 +0200)
Problem:    Command line history not read from viminfo on startup.
Solution:   Get history length after initializing it.

src/testdir/test_viminfo.vim
src/version.c
src/viminfo.c

index cea78e574808171be4ffc5728a7afc122a274cc8..8206458d9ea2f3f9687e166353b5f3a4b3af564b 100644 (file)
@@ -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',
index 69baf5439064ca7cd3eb89a7e8d8de75c04374d5..d8b3dfedb83aa903456ca22d88ef65b499687b23 100644 (file)
@@ -777,6 +777,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1731,
 /**/
     1730,
 /**/
index 88801444618f0720bad90c0fbe1f32bcd91d7428..7e192cecd7ae681857954c29d6a8312eb724f012 100644 (file)
@@ -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);