Mercurial > vim
comparison src/undo.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 | c43e99e9baaf |
comparison
equal
deleted
inserted
replaced
2481:734196b073e0 | 2482:88751831fa0a |
---|---|
2921 u_unch_branch(buf->b_u_oldhead); | 2921 u_unch_branch(buf->b_u_oldhead); |
2922 buf->b_did_warn = FALSE; | 2922 buf->b_did_warn = FALSE; |
2923 } | 2923 } |
2924 | 2924 |
2925 /* | 2925 /* |
2926 * After reloading a buffer which was saved for 'undoreload': Find the first | |
2927 * line that was changed and set the cursor there. | |
2928 */ | |
2929 void | |
2930 u_find_first_changed() | |
2931 { | |
2932 u_header_T *uhp = curbuf->b_u_newhead; | |
2933 u_entry_T *uep; | |
2934 linenr_T lnum; | |
2935 | |
2936 if (curbuf->b_u_curhead != NULL || uhp == NULL) | |
2937 return; /* undid something in an autocmd? */ | |
2938 | |
2939 /* Check that the last undo block was for the whole file. */ | |
2940 uep = uhp->uh_entry; | |
2941 if (uep->ue_top != 0 || uep->ue_bot != 0) | |
2942 return; | |
2943 | |
2944 for (lnum = 1; lnum < curbuf->b_ml.ml_line_count | |
2945 && lnum <= uep->ue_size; ++lnum) | |
2946 if (STRCMP(ml_get_buf(curbuf, lnum, FALSE), | |
2947 uep->ue_array[lnum - 1]) != 0) | |
2948 { | |
2949 clearpos(&(uhp->uh_cursor)); | |
2950 uhp->uh_cursor.lnum = lnum; | |
2951 return; | |
2952 } | |
2953 if (curbuf->b_ml.ml_line_count != uep->ue_size) | |
2954 { | |
2955 /* lines added or deleted at the end, put the cursor there */ | |
2956 clearpos(&(uhp->uh_cursor)); | |
2957 uhp->uh_cursor.lnum = lnum; | |
2958 } | |
2959 } | |
2960 | |
2961 /* | |
2926 * Increase the write count, store it in the last undo header, what would be | 2962 * Increase the write count, store it in the last undo header, what would be |
2927 * used for "u". | 2963 * used for "u". |
2928 */ | 2964 */ |
2929 void | 2965 void |
2930 u_update_save_nr(buf) | 2966 u_update_save_nr(buf) |