]> granicus.if.org Git - vim/commitdiff
patch 8.2.2494: ":rviminfo!" clears most of oldfiles v8.2.2494
authorBram Moolenaar <Bram@vim.org>
Wed, 10 Feb 2021 18:22:15 +0000 (19:22 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 10 Feb 2021 18:22:15 +0000 (19:22 +0100)
Problem:    ":rviminfo!" clears most of oldfiles.
Solution:   Add VIF_ONLY_CURBUF to read_viminfo(). (closes #1781)

src/version.c
src/vim.h
src/viminfo.c

index d787ca7b67453104c6ef48abf6e22fba5d3376fc..88cbd07022399332cbef4dc3178be6c3da6cbe89 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2494,
 /**/
     2493,
 /**/
index de2482e8b8bcc7d05d82a103a9cc24e975803675..73cb2692e63984b97da607814aadc8c62528c146 100644 (file)
--- a/src/vim.h
+++ b/src/vim.h
@@ -2458,10 +2458,11 @@ typedef enum {
 #define DOSO_GVIMRC    2       // loading gvimrc file
 
 // flags for read_viminfo() and children
-#define VIF_WANT_INFO          1       // load non-mark info
-#define VIF_WANT_MARKS         2       // load file marks
-#define VIF_FORCEIT            4       // overwrite info already read
-#define VIF_GET_OLDFILES       8       // load v:oldfiles
+#define VIF_WANT_INFO      1   // load non-mark info
+#define VIF_WANT_MARKS     2   // load file marks
+#define VIF_ONLY_CURBUF            4   // bail out after loading marks for curbuf
+#define VIF_FORCEIT        8   // overwrite info already read
+#define VIF_GET_OLDFILES    16 // load v:oldfiles
 
 // flags for buf_freeall()
 #define BFA_DEL                 1      // buffer is going to be deleted
index 0ec9a131938aace5827cb1aa21c7d48e5cb615bf..aca24317934995a0b0a5d3763213ca762af07b39 100644 (file)
@@ -2219,7 +2219,8 @@ buf_compare(const void *s1, const void *s2)
 /*
  * Handle marks in the viminfo file:
  * fp_out != NULL: copy marks, in time order with buffers in "buflist".
- * fp_out == NULL && (flags & VIF_WANT_MARKS): read marks for curbuf only
+ * fp_out == NULL && (flags & VIF_WANT_MARKS): read marks for curbuf
+ * fp_out == NULL && (flags & VIF_ONLY_CURBUF): bail out after curbuf marks
  * fp_out == NULL && (flags & VIF_GET_OLDFILES | VIF_FORCEIT): fill v:oldfiles
  */
     static void
@@ -2448,7 +2449,8 @@ copy_viminfo_marks(
                    wp->w_changelistidx = curbuf->b_changelistlen;
            }
 #endif
-           break;
+           if (flags & VIF_ONLY_CURBUF)
+               break;
        }
     }
 
@@ -2473,7 +2475,7 @@ check_marks_read(void)
 {
     if (!curbuf->b_marks_read && get_viminfo_parameter('\'') > 0
                                                  && curbuf->b_ffname != NULL)
-       read_viminfo(NULL, VIF_WANT_MARKS);
+       read_viminfo(NULL, VIF_WANT_MARKS | VIF_ONLY_CURBUF);
 
     // Always set b_marks_read; needed when 'viminfo' is changed to include
     // the ' parameter after opening a buffer.
@@ -2953,8 +2955,8 @@ do_viminfo(FILE *fp_in, FILE *fp_out, int flags)
                    && vir.vir_line[0] != '>')
                ;
 
-       do_copy_marks = (flags &
-                          (VIF_WANT_MARKS | VIF_GET_OLDFILES | VIF_FORCEIT));
+       do_copy_marks = (flags & (VIF_WANT_MARKS | VIF_ONLY_CURBUF
+                                           | VIF_GET_OLDFILES | VIF_FORCEIT));
     }
 
     if (fp_out != NULL)