Mercurial > vim
comparison src/undo.c @ 2288:4dda2bd944e1 vim73
Apply patch 7.2.445.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 07 Jul 2010 18:26:28 +0200 |
parents | a888ed7ba375 |
children | 3331756e4232 |
comparison
equal
deleted
inserted
replaced
2287:573da4dac306 | 2288:4dda2bd944e1 |
---|---|
194 /* Check the next header in this branch. */ | 194 /* Check the next header in this branch. */ |
195 u_check_tree(uhp->uh_prev.ptr, uhp, NULL); | 195 u_check_tree(uhp->uh_prev.ptr, uhp, NULL); |
196 } | 196 } |
197 } | 197 } |
198 | 198 |
199 void | 199 static void |
200 u_check(int newhead_may_be_NULL) | 200 u_check(int newhead_may_be_NULL) |
201 { | 201 { |
202 seen_b_u_newhead = 0; | 202 seen_b_u_newhead = 0; |
203 seen_b_u_curhead = 0; | 203 seen_b_u_curhead = 0; |
204 header_count = 0; | 204 header_count = 0; |
329 } | 329 } |
330 | 330 |
331 return TRUE; | 331 return TRUE; |
332 } | 332 } |
333 | 333 |
334 /* | |
335 * Common code for various ways to save text before a change. | |
336 */ | |
334 static int | 337 static int |
335 u_savecommon(top, bot, newbot) | 338 u_savecommon(top, bot, newbot) |
336 linenr_T top, bot; | 339 linenr_T top, bot; |
337 linenr_T newbot; | 340 linenr_T newbot; |
338 { | 341 { |
383 #endif | 386 #endif |
384 | 387 |
385 size = bot - top - 1; | 388 size = bot - top - 1; |
386 | 389 |
387 /* | 390 /* |
388 * if curbuf->b_u_synced == TRUE make a new header | 391 * If curbuf->b_u_synced == TRUE make a new header. |
389 */ | 392 */ |
390 if (curbuf->b_u_synced) | 393 if (curbuf->b_u_synced) |
391 { | 394 { |
392 #ifdef FEAT_JUMPLIST | 395 #ifdef FEAT_JUMPLIST |
393 /* Need to create new entry in b_changelist. */ | 396 /* Need to create new entry in b_changelist. */ |
1936 u_oldcount = 0; | 1939 u_oldcount = 0; |
1937 if (curbuf->b_ml.ml_flags & ML_EMPTY) | 1940 if (curbuf->b_ml.ml_flags & ML_EMPTY) |
1938 u_oldcount = -1; | 1941 u_oldcount = -1; |
1939 while (count--) | 1942 while (count--) |
1940 { | 1943 { |
1944 /* Do the change warning now, so that it triggers FileChangedRO when | |
1945 * needed. This may cause the file to be reloaded, that must happen | |
1946 * before we do anything, because it may change curbuf->b_u_curhead | |
1947 * and more. */ | |
1948 change_warning(0); | |
1949 | |
1941 if (undo_undoes) | 1950 if (undo_undoes) |
1942 { | 1951 { |
1943 if (curbuf->b_u_curhead == NULL) /* first undo */ | 1952 if (curbuf->b_u_curhead == NULL) /* first undo */ |
1944 curbuf->b_u_curhead = curbuf->b_u_newhead; | 1953 curbuf->b_u_curhead = curbuf->b_u_newhead; |
1945 else if (p_ul > 0) /* multi level undo */ | 1954 else if (p_ul > 0) /* multi level undo */ |
2228 if (uhp != NULL) | 2237 if (uhp != NULL) |
2229 { | 2238 { |
2230 /* | 2239 /* |
2231 * First go up the tree as much as needed. | 2240 * First go up the tree as much as needed. |
2232 */ | 2241 */ |
2233 for (;;) | 2242 while (!got_int) |
2234 { | 2243 { |
2244 /* Do the change warning now, for the same reason as above. */ | |
2245 change_warning(0); | |
2246 | |
2235 uhp = curbuf->b_u_curhead; | 2247 uhp = curbuf->b_u_curhead; |
2236 if (uhp == NULL) | 2248 if (uhp == NULL) |
2237 uhp = curbuf->b_u_newhead; | 2249 uhp = curbuf->b_u_newhead; |
2238 else | 2250 else |
2239 uhp = uhp->uh_next.ptr; | 2251 uhp = uhp->uh_next.ptr; |
2246 } | 2258 } |
2247 | 2259 |
2248 /* | 2260 /* |
2249 * And now go down the tree (redo), branching off where needed. | 2261 * And now go down the tree (redo), branching off where needed. |
2250 */ | 2262 */ |
2251 uhp = curbuf->b_u_curhead; | 2263 while (!got_int) |
2252 while (uhp != NULL) | 2264 { |
2253 { | 2265 /* Do the change warning now, for the same reason as above. */ |
2266 change_warning(0); | |
2267 | |
2268 uhp = curbuf->b_u_curhead; | |
2269 if (uhp == NULL) | |
2270 break; | |
2271 | |
2254 /* Go back to the first branch with a mark. */ | 2272 /* Go back to the first branch with a mark. */ |
2255 while (uhp->uh_alt_prev.ptr != NULL | 2273 while (uhp->uh_alt_prev.ptr != NULL |
2256 && uhp->uh_alt_prev.ptr->uh_walk == mark) | 2274 && uhp->uh_alt_prev.ptr->uh_walk == mark) |
2257 uhp = uhp->uh_alt_prev.ptr; | 2275 uhp = uhp->uh_alt_prev.ptr; |
2258 | 2276 |
2347 visualinfo_T visualinfo; | 2365 visualinfo_T visualinfo; |
2348 #endif | 2366 #endif |
2349 int empty_buffer; /* buffer became empty */ | 2367 int empty_buffer; /* buffer became empty */ |
2350 u_header_T *curhead = curbuf->b_u_curhead; | 2368 u_header_T *curhead = curbuf->b_u_curhead; |
2351 | 2369 |
2370 #ifdef FEAT_AUTOCMD | |
2371 /* Don't want autocommands using the undo structures here, they are | |
2372 * invalid till the end. */ | |
2373 block_autocmds(); | |
2374 #endif | |
2375 | |
2352 #ifdef U_DEBUG | 2376 #ifdef U_DEBUG |
2353 u_check(FALSE); | 2377 u_check(FALSE); |
2354 #endif | 2378 #endif |
2355 old_flags = curhead->uh_flags; | 2379 old_flags = curhead->uh_flags; |
2356 new_flags = (curbuf->b_changed ? UH_CHANGED : 0) + | 2380 new_flags = (curbuf->b_changed ? UH_CHANGED : 0) + |
2376 if (bot == 0) | 2400 if (bot == 0) |
2377 bot = curbuf->b_ml.ml_line_count + 1; | 2401 bot = curbuf->b_ml.ml_line_count + 1; |
2378 if (top > curbuf->b_ml.ml_line_count || top >= bot | 2402 if (top > curbuf->b_ml.ml_line_count || top >= bot |
2379 || bot > curbuf->b_ml.ml_line_count + 1) | 2403 || bot > curbuf->b_ml.ml_line_count + 1) |
2380 { | 2404 { |
2405 #ifdef FEAT_AUTOCMD | |
2406 unblock_autocmds(); | |
2407 #endif | |
2381 EMSG(_("E438: u_undo: line numbers wrong")); | 2408 EMSG(_("E438: u_undo: line numbers wrong")); |
2382 changed(); /* don't want UNCHANGED now */ | 2409 changed(); /* don't want UNCHANGED now */ |
2383 return; | 2410 return; |
2384 } | 2411 } |
2385 | 2412 |
2590 } | 2617 } |
2591 | 2618 |
2592 /* The timestamp can be the same for multiple changes, just use the one of | 2619 /* The timestamp can be the same for multiple changes, just use the one of |
2593 * the undone/redone change. */ | 2620 * the undone/redone change. */ |
2594 curbuf->b_u_time_cur = curhead->uh_time; | 2621 curbuf->b_u_time_cur = curhead->uh_time; |
2622 | |
2623 #ifdef FEAT_AUTOCMD | |
2624 unblock_autocmds(); | |
2625 #endif | |
2595 #ifdef U_DEBUG | 2626 #ifdef U_DEBUG |
2596 u_check(FALSE); | 2627 u_check(FALSE); |
2597 #endif | 2628 #endif |
2598 } | 2629 } |
2599 | 2630 |