diff src/fileio.c @ 18619:788d76db02ac v8.1.2302

patch 8.1.2302: :lockmarks does not work for '[ and '] Commit: https://github.com/vim/vim/commit/f4a1d1c0542df151bc59ac3b798ed198b5c71ccc Author: Bram Moolenaar <Bram@vim.org> Date: Sat Nov 16 13:50:25 2019 +0100 patch 8.1.2302: :lockmarks does not work for '[ and '] Problem: :lockmarks does not work for '[ and ']. Solution: save and restore '[ and '] marks. (James McCoy, closes https://github.com/vim/vim/issues/5222)
author Bram Moolenaar <Bram@vim.org>
date Sat, 16 Nov 2019 14:00:05 +0100
parents e2be5a6485f5
children bbea1f108187
line wrap: on
line diff
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -188,6 +188,7 @@ readfile(
 					   wasn't possible */
     char_u	conv_rest[CONV_RESTLEN];
     int		conv_restlen = 0;	/* nr of bytes in conv_rest[] */
+    pos_T	orig_start;
     buf_T	*old_curbuf;
     char_u	*old_b_ffname;
     char_u	*old_b_fname;
@@ -250,9 +251,7 @@ readfile(
      */
     if (!filtering && !read_stdin && !read_buffer)
     {
-	pos_T	    pos;
-
-	pos = curbuf->b_op_start;
+	orig_start = curbuf->b_op_start;
 
 	/* Set '[ mark to the line above where the lines go (line 1 if zero). */
 	curbuf->b_op_start.lnum = ((from == 0) ? 1 : from);
@@ -276,7 +275,7 @@ readfile(
 	    return OK;
 #endif
 
-	curbuf->b_op_start = pos;
+	curbuf->b_op_start = orig_start;
     }
 
     if ((shortmess(SHM_OVER) || curbuf->b_help) && p_verbose == 0)
@@ -617,6 +616,7 @@ readfile(
     /*
      * Set '[ mark to the line above where the lines go (line 1 if zero).
      */
+    orig_start = curbuf->b_op_start;
     curbuf->b_op_start.lnum = ((from == 0) ? 1 : from);
     curbuf->b_op_start.col = 0;
 
@@ -658,6 +658,7 @@ readfile(
 	try_mac = (vim_strchr(p_ffs, 'm') != NULL);
 	try_dos = (vim_strchr(p_ffs, 'd') != NULL);
 	try_unix = (vim_strchr(p_ffs, 'x') != NULL);
+	curbuf->b_op_start = orig_start;
 
 	if (msg_scrolled == n)
 	    msg_scroll = m;
@@ -2471,13 +2472,14 @@ failed:
 	check_cursor_lnum();
 	beginline(BL_WHITE | BL_FIX);	    /* on first non-blank */
 
-	/*
-	 * Set '[ and '] marks to the newly read lines.
-	 */
-	curbuf->b_op_start.lnum = from + 1;
-	curbuf->b_op_start.col = 0;
-	curbuf->b_op_end.lnum = from + linecnt;
-	curbuf->b_op_end.col = 0;
+	if (!cmdmod.lockmarks)
+	{
+	    // Set '[ and '] marks to the newly read lines.
+	    curbuf->b_op_start.lnum = from + 1;
+	    curbuf->b_op_start.col = 0;
+	    curbuf->b_op_end.lnum = from + linecnt;
+	    curbuf->b_op_end.col = 0;
+	}
 
 #ifdef MSWIN
 	/*