diff src/viminfo.c @ 23903:402f1d8653c1 v8.2.2494

patch 8.2.2494: ":rviminfo!" clears most of oldfiles Commit: https://github.com/vim/vim/commit/3ff656f6b43465083b58e1d2fb9b8008abc5bc17 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Feb 10 19:22:15 2021 +0100 patch 8.2.2494: ":rviminfo!" clears most of oldfiles Problem: ":rviminfo!" clears most of oldfiles. Solution: Add VIF_ONLY_CURBUF to read_viminfo(). (closes https://github.com/vim/vim/issues/1781)
author Bram Moolenaar <Bram@vim.org>
date Wed, 10 Feb 2021 19:30:04 +0100
parents 2d6d70a913c1
children a4fda40e0bb9
line wrap: on
line diff
--- a/src/viminfo.c
+++ b/src/viminfo.c
@@ -2219,7 +2219,8 @@ buf_compare(const void *s1, const void *
 /*
  * 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, in
 		    && 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)