comparison 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
comparison
equal deleted inserted replaced
18618:74422854344d 18619:788d76db02ac
681 #ifdef FEAT_PERSISTENT_UNDO 681 #ifdef FEAT_PERSISTENT_UNDO
682 int write_undo_file = FALSE; 682 int write_undo_file = FALSE;
683 context_sha256_T sha_ctx; 683 context_sha256_T sha_ctx;
684 #endif 684 #endif
685 unsigned int bkc = get_bkc_value(buf); 685 unsigned int bkc = get_bkc_value(buf);
686 pos_T orig_start = buf->b_op_start;
687 pos_T orig_end = buf->b_op_end;
686 688
687 if (fname == NULL || *fname == NUL) // safety check 689 if (fname == NULL || *fname == NUL) // safety check
688 return FAIL; 690 return FAIL;
689 if (buf->b_ml.ml_mfp == NULL) 691 if (buf->b_ml.ml_mfp == NULL)
690 { 692 {
873 #ifdef FEAT_EVAL 875 #ifdef FEAT_EVAL
874 || aborting() 876 || aborting()
875 #endif 877 #endif
876 ) 878 )
877 { 879 {
880 if (buf != NULL && cmdmod.lockmarks)
881 {
882 // restore the original '[ and '] positions
883 buf->b_op_start = orig_start;
884 buf->b_op_end = orig_end;
885 }
886
878 --no_wait_return; 887 --no_wait_return;
879 msg_scroll = msg_save; 888 msg_scroll = msg_save;
880 if (nofile_err) 889 if (nofile_err)
881 emsg(_("E676: No matching autocommands for acwrite buffer")); 890 emsg(_("E676: No matching autocommands for acwrite buffer"));
882 891
948 sfname = buf->b_sfname; 957 sfname = buf->b_sfname;
949 if (buf_fname_f) 958 if (buf_fname_f)
950 fname = buf->b_ffname; 959 fname = buf->b_ffname;
951 if (buf_fname_s) 960 if (buf_fname_s)
952 fname = buf->b_sfname; 961 fname = buf->b_sfname;
962 }
963
964 if (cmdmod.lockmarks)
965 {
966 // restore the original '[ and '] positions
967 buf->b_op_start = orig_start;
968 buf->b_op_end = orig_end;
953 } 969 }
954 970
955 #ifdef FEAT_NETBEANS_INTG 971 #ifdef FEAT_NETBEANS_INTG
956 if (netbeans_active() && isNetbeansBuffer(buf)) 972 if (netbeans_active() && isNetbeansBuffer(buf))
957 { 973 {