comparison src/ex_cmds.c @ 2394:a3aca345aafa vim73

Add the 'undoreload' option to be able to undo a file reload.
author Bram Moolenaar <bram@vim.org>
date Sat, 24 Jul 2010 20:27:03 +0200
parents ccda151dde4e
children 298d8d6e69be
comparison
equal deleted inserted replaced
2393:210a5605e126 2394:a3aca345aafa
3142 #endif 3142 #endif
3143 char_u *command = NULL; 3143 char_u *command = NULL;
3144 #ifdef FEAT_SPELL 3144 #ifdef FEAT_SPELL
3145 int did_get_winopts = FALSE; 3145 int did_get_winopts = FALSE;
3146 #endif 3146 #endif
3147 int readfile_flags = 0;
3147 3148
3148 if (eap != NULL) 3149 if (eap != NULL)
3149 command = eap->do_ecmd_cmd; 3150 command = eap->do_ecmd_cmd;
3150 3151
3151 if (fnum != 0) 3152 if (fnum != 0)
3568 if (buf->b_fname != NULL) 3569 if (buf->b_fname != NULL)
3569 new_name = vim_strsave(buf->b_fname); 3570 new_name = vim_strsave(buf->b_fname);
3570 else 3571 else
3571 new_name = NULL; 3572 new_name = NULL;
3572 #endif 3573 #endif
3573 buf_freeall(curbuf, FALSE, FALSE); /* free all things for buffer */ 3574 if (p_ur < 0 || curbuf->b_ml.ml_line_count <= p_ur)
3575 {
3576 /* Save all the text, so that the reload can be undone.
3577 * Sync first so that this is a separate undo-able action. */
3578 u_sync(FALSE);
3579 if (u_savecommon(0, curbuf->b_ml.ml_line_count + 1, 0, TRUE)
3580 == FAIL)
3581 goto theend;
3582 u_unchanged(curbuf);
3583 buf_freeall(curbuf, BFA_KEEP_UNDO);
3584
3585 /* tell readfile() not to clear or reload undo info */
3586 readfile_flags = READ_KEEP_UNDO;
3587 }
3588 else
3589 buf_freeall(curbuf, 0); /* free all things for buffer */
3574 #ifdef FEAT_AUTOCMD 3590 #ifdef FEAT_AUTOCMD
3575 /* If autocommands deleted the buffer we were going to re-edit, give 3591 /* If autocommands deleted the buffer we were going to re-edit, give
3576 * up and jump to the end. */ 3592 * up and jump to the end. */
3577 if (!buf_valid(buf)) 3593 if (!buf_valid(buf))
3578 { 3594 {
3665 3681
3666 /* 3682 /*
3667 * Open the buffer and read the file. 3683 * Open the buffer and read the file.
3668 */ 3684 */
3669 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) 3685 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
3670 if (should_abort(open_buffer(FALSE, eap))) 3686 if (should_abort(open_buffer(FALSE, eap, readfile_flags)))
3671 retval = FAIL; 3687 retval = FAIL;
3672 #else 3688 #else
3673 (void)open_buffer(FALSE, eap); 3689 (void)open_buffer(FALSE, eap, readfile_flags);
3674 #endif 3690 #endif
3675 3691
3676 #if defined(HAS_SWAP_EXISTS_ACTION) 3692 #if defined(HAS_SWAP_EXISTS_ACTION)
3677 if (swap_exists_action == SEA_QUIT) 3693 if (swap_exists_action == SEA_QUIT)
3678 retval = FAIL; 3694 retval = FAIL;