diff src/bufwrite.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 4481f3b29fc5
line wrap: on
line diff
--- a/src/bufwrite.c
+++ b/src/bufwrite.c
@@ -683,6 +683,8 @@ buf_write(
     context_sha256_T sha_ctx;
 #endif
     unsigned int    bkc = get_bkc_value(buf);
+    pos_T	    orig_start = buf->b_op_start;
+    pos_T	    orig_end = buf->b_op_end;
 
     if (fname == NULL || *fname == NUL)	// safety check
 	return FAIL;
@@ -875,6 +877,13 @@ buf_write(
 #endif
 				       )
 	{
+	    if (buf != NULL && cmdmod.lockmarks)
+	    {
+		// restore the original '[ and '] positions
+		buf->b_op_start = orig_start;
+		buf->b_op_end = orig_end;
+	    }
+
 	    --no_wait_return;
 	    msg_scroll = msg_save;
 	    if (nofile_err)
@@ -952,6 +961,13 @@ buf_write(
 	    fname = buf->b_sfname;
     }
 
+    if (cmdmod.lockmarks)
+    {
+	// restore the original '[ and '] positions
+	buf->b_op_start = orig_start;
+	buf->b_op_end = orig_end;
+    }
+
 #ifdef FEAT_NETBEANS_INTG
     if (netbeans_active() && isNetbeansBuffer(buf))
     {