comparison 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
comparison
equal deleted inserted replaced
18618:74422854344d 18619:788d76db02ac
186 int converted = FALSE; /* TRUE if conversion done */ 186 int converted = FALSE; /* TRUE if conversion done */
187 int notconverted = FALSE; /* TRUE if conversion wanted but it 187 int notconverted = FALSE; /* TRUE if conversion wanted but it
188 wasn't possible */ 188 wasn't possible */
189 char_u conv_rest[CONV_RESTLEN]; 189 char_u conv_rest[CONV_RESTLEN];
190 int conv_restlen = 0; /* nr of bytes in conv_rest[] */ 190 int conv_restlen = 0; /* nr of bytes in conv_rest[] */
191 pos_T orig_start;
191 buf_T *old_curbuf; 192 buf_T *old_curbuf;
192 char_u *old_b_ffname; 193 char_u *old_b_ffname;
193 char_u *old_b_fname; 194 char_u *old_b_fname;
194 int using_b_ffname; 195 int using_b_ffname;
195 int using_b_fname; 196 int using_b_fname;
248 * The BufReadCmd and FileReadCmd events intercept the reading process by 249 * The BufReadCmd and FileReadCmd events intercept the reading process by
249 * executing the associated commands instead. 250 * executing the associated commands instead.
250 */ 251 */
251 if (!filtering && !read_stdin && !read_buffer) 252 if (!filtering && !read_stdin && !read_buffer)
252 { 253 {
253 pos_T pos; 254 orig_start = curbuf->b_op_start;
254
255 pos = curbuf->b_op_start;
256 255
257 /* Set '[ mark to the line above where the lines go (line 1 if zero). */ 256 /* Set '[ mark to the line above where the lines go (line 1 if zero). */
258 curbuf->b_op_start.lnum = ((from == 0) ? 1 : from); 257 curbuf->b_op_start.lnum = ((from == 0) ? 1 : from);
259 curbuf->b_op_start.col = 0; 258 curbuf->b_op_start.col = 0;
260 259
274 return aborting() ? FAIL : OK; 273 return aborting() ? FAIL : OK;
275 #else 274 #else
276 return OK; 275 return OK;
277 #endif 276 #endif
278 277
279 curbuf->b_op_start = pos; 278 curbuf->b_op_start = orig_start;
280 } 279 }
281 280
282 if ((shortmess(SHM_OVER) || curbuf->b_help) && p_verbose == 0) 281 if ((shortmess(SHM_OVER) || curbuf->b_help) && p_verbose == 0)
283 msg_scroll = FALSE; /* overwrite previous file message */ 282 msg_scroll = FALSE; /* overwrite previous file message */
284 else 283 else
615 ++no_wait_return; /* don't wait for return yet */ 614 ++no_wait_return; /* don't wait for return yet */
616 615
617 /* 616 /*
618 * Set '[ mark to the line above where the lines go (line 1 if zero). 617 * Set '[ mark to the line above where the lines go (line 1 if zero).
619 */ 618 */
619 orig_start = curbuf->b_op_start;
620 curbuf->b_op_start.lnum = ((from == 0) ? 1 : from); 620 curbuf->b_op_start.lnum = ((from == 0) ? 1 : from);
621 curbuf->b_op_start.col = 0; 621 curbuf->b_op_start.col = 0;
622 622
623 try_mac = (vim_strchr(p_ffs, 'm') != NULL); 623 try_mac = (vim_strchr(p_ffs, 'm') != NULL);
624 try_dos = (vim_strchr(p_ffs, 'd') != NULL); 624 try_dos = (vim_strchr(p_ffs, 'd') != NULL);
656 FALSE, NULL, eap); 656 FALSE, NULL, eap);
657 /* autocommands may have changed it */ 657 /* autocommands may have changed it */
658 try_mac = (vim_strchr(p_ffs, 'm') != NULL); 658 try_mac = (vim_strchr(p_ffs, 'm') != NULL);
659 try_dos = (vim_strchr(p_ffs, 'd') != NULL); 659 try_dos = (vim_strchr(p_ffs, 'd') != NULL);
660 try_unix = (vim_strchr(p_ffs, 'x') != NULL); 660 try_unix = (vim_strchr(p_ffs, 'x') != NULL);
661 curbuf->b_op_start = orig_start;
661 662
662 if (msg_scrolled == n) 663 if (msg_scrolled == n)
663 msg_scroll = m; 664 msg_scroll = m;
664 665
665 #ifdef FEAT_EVAL 666 #ifdef FEAT_EVAL
2469 else 2470 else
2470 curwin->w_cursor.lnum = from + 1; 2471 curwin->w_cursor.lnum = from + 1;
2471 check_cursor_lnum(); 2472 check_cursor_lnum();
2472 beginline(BL_WHITE | BL_FIX); /* on first non-blank */ 2473 beginline(BL_WHITE | BL_FIX); /* on first non-blank */
2473 2474
2474 /* 2475 if (!cmdmod.lockmarks)
2475 * Set '[ and '] marks to the newly read lines. 2476 {
2476 */ 2477 // Set '[ and '] marks to the newly read lines.
2477 curbuf->b_op_start.lnum = from + 1; 2478 curbuf->b_op_start.lnum = from + 1;
2478 curbuf->b_op_start.col = 0; 2479 curbuf->b_op_start.col = 0;
2479 curbuf->b_op_end.lnum = from + linecnt; 2480 curbuf->b_op_end.lnum = from + linecnt;
2480 curbuf->b_op_end.col = 0; 2481 curbuf->b_op_end.col = 0;
2482 }
2481 2483
2482 #ifdef MSWIN 2484 #ifdef MSWIN
2483 /* 2485 /*
2484 * Work around a weird problem: When a file has two links (only 2486 * Work around a weird problem: When a file has two links (only
2485 * possible on NTFS) and we write through one link, then stat() it 2487 * possible on NTFS) and we write through one link, then stat() it