Mercurial > vim
comparison src/fileio.c @ 2482:88751831fa0a vim73
When undoing a reload, move the cursor to the first changed line.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 04 Aug 2010 14:29:54 +0200 |
parents | 8f6106dd3d12 |
children | 0dffdd8f8871 |
comparison
equal
deleted
inserted
replaced
2481:734196b073e0 | 2482:88751831fa0a |
---|---|
2603 * an eol for when writing it again. This is required for | 2603 * an eol for when writing it again. This is required for |
2604 * ":autocmd FileReadPost *.gz set bin|'[,']!gunzip" to work. | 2604 * ":autocmd FileReadPost *.gz set bin|'[,']!gunzip" to work. |
2605 */ | 2605 */ |
2606 write_no_eol_lnum = read_no_eol_lnum; | 2606 write_no_eol_lnum = read_no_eol_lnum; |
2607 | 2607 |
2608 /* When reloading a buffer put the cursor at the first line that is | |
2609 * different. */ | |
2610 if (flags & READ_KEEP_UNDO) | |
2611 u_find_first_changed(); | |
2612 | |
2608 #ifdef FEAT_PERSISTENT_UNDO | 2613 #ifdef FEAT_PERSISTENT_UNDO |
2609 /* | 2614 /* |
2610 * When opening a new file locate undo info and read it. | 2615 * When opening a new file locate undo info and read it. |
2611 */ | 2616 */ |
2612 if (read_undo_file) | 2617 if (read_undo_file) |
7093 if (prep_exarg(&ea, buf) == OK) | 7098 if (prep_exarg(&ea, buf) == OK) |
7094 { | 7099 { |
7095 old_cursor = curwin->w_cursor; | 7100 old_cursor = curwin->w_cursor; |
7096 old_topline = curwin->w_topline; | 7101 old_topline = curwin->w_topline; |
7097 | 7102 |
7098 if (saved == OK && (p_ur < 0 || curbuf->b_ml.ml_line_count <= p_ur)) | 7103 if (p_ur < 0 || curbuf->b_ml.ml_line_count <= p_ur) |
7099 { | 7104 { |
7100 /* Save all the text, so that the reload can be undone. | 7105 /* Save all the text, so that the reload can be undone. |
7101 * Sync first so that this is a separate undo-able action. */ | 7106 * Sync first so that this is a separate undo-able action. */ |
7102 u_sync(FALSE); | 7107 u_sync(FALSE); |
7103 saved = u_savecommon(0, curbuf->b_ml.ml_line_count + 1, 0, TRUE); | 7108 saved = u_savecommon(0, curbuf->b_ml.ml_line_count + 1, 0, TRUE); |
7167 { | 7172 { |
7168 u_blockfree(buf); | 7173 u_blockfree(buf); |
7169 u_clearall(buf); | 7174 u_clearall(buf); |
7170 } | 7175 } |
7171 else | 7176 else |
7177 { | |
7172 /* Mark all undo states as changed. */ | 7178 /* Mark all undo states as changed. */ |
7173 u_unchanged(curbuf); | 7179 u_unchanged(curbuf); |
7180 } | |
7174 } | 7181 } |
7175 } | 7182 } |
7176 vim_free(ea.cmd); | 7183 vim_free(ea.cmd); |
7177 | 7184 |
7178 if (savebuf != NULL && buf_valid(savebuf)) | 7185 if (savebuf != NULL && buf_valid(savebuf)) |