Mercurial > vim
comparison src/undo.c @ 15636:6f1c7e9a6393 v8.1.0826
patch 8.1.0826: too many #ifdefs
commit https://github.com/vim/vim/commit/29ddebef4038d2d2b3bc9d8d3b0109f4046d6fbf
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jan 26 17:28:26 2019 +0100
patch 8.1.0826: too many #ifdefs
Problem: Too many #ifdefs.
Solution: Graduate FEAT_VIRTUALEDIT. Adds about 10Kbyte to the code.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 26 Jan 2019 17:30:15 +0100 |
parents | dd725a8ab112 |
children | 7fad90423bd2 |
comparison
equal
deleted
inserted
replaced
15635:c51d2a06f5f9 | 15636:6f1c7e9a6393 |
---|---|
546 | 546 |
547 uhp->uh_walk = 0; | 547 uhp->uh_walk = 0; |
548 uhp->uh_entry = NULL; | 548 uhp->uh_entry = NULL; |
549 uhp->uh_getbot_entry = NULL; | 549 uhp->uh_getbot_entry = NULL; |
550 uhp->uh_cursor = curwin->w_cursor; /* save cursor pos. for undo */ | 550 uhp->uh_cursor = curwin->w_cursor; /* save cursor pos. for undo */ |
551 #ifdef FEAT_VIRTUALEDIT | |
552 if (virtual_active() && curwin->w_cursor.coladd > 0) | 551 if (virtual_active() && curwin->w_cursor.coladd > 0) |
553 uhp->uh_cursor_vcol = getviscol(); | 552 uhp->uh_cursor_vcol = getviscol(); |
554 else | 553 else |
555 uhp->uh_cursor_vcol = -1; | 554 uhp->uh_cursor_vcol = -1; |
556 #endif | |
557 | 555 |
558 /* save changed and buffer empty flag for undo */ | 556 /* save changed and buffer empty flag for undo */ |
559 uhp->uh_flags = (curbuf->b_changed ? UH_CHANGED : 0) + | 557 uhp->uh_flags = (curbuf->b_changed ? UH_CHANGED : 0) + |
560 ((curbuf->b_ml.ml_flags & ML_EMPTY) ? UH_EMPTYBUF : 0); | 558 ((curbuf->b_ml.ml_flags & ML_EMPTY) ? UH_EMPTYBUF : 0); |
561 | 559 |
1248 put_header_ptr(bi, uhp->uh_prev.ptr); | 1246 put_header_ptr(bi, uhp->uh_prev.ptr); |
1249 put_header_ptr(bi, uhp->uh_alt_next.ptr); | 1247 put_header_ptr(bi, uhp->uh_alt_next.ptr); |
1250 put_header_ptr(bi, uhp->uh_alt_prev.ptr); | 1248 put_header_ptr(bi, uhp->uh_alt_prev.ptr); |
1251 undo_write_bytes(bi, uhp->uh_seq, 4); | 1249 undo_write_bytes(bi, uhp->uh_seq, 4); |
1252 serialize_pos(bi, uhp->uh_cursor); | 1250 serialize_pos(bi, uhp->uh_cursor); |
1253 #ifdef FEAT_VIRTUALEDIT | |
1254 undo_write_bytes(bi, (long_u)uhp->uh_cursor_vcol, 4); | 1251 undo_write_bytes(bi, (long_u)uhp->uh_cursor_vcol, 4); |
1255 #else | |
1256 undo_write_bytes(bi, (long_u)0, 4); | |
1257 #endif | |
1258 undo_write_bytes(bi, (long_u)uhp->uh_flags, 2); | 1252 undo_write_bytes(bi, (long_u)uhp->uh_flags, 2); |
1259 /* Assume NMARKS will stay the same. */ | 1253 /* Assume NMARKS will stay the same. */ |
1260 for (i = 0; i < NMARKS; ++i) | 1254 for (i = 0; i < NMARKS; ++i) |
1261 serialize_pos(bi, uhp->uh_namedm[i]); | 1255 serialize_pos(bi, uhp->uh_namedm[i]); |
1262 serialize_visualinfo(bi, &uhp->uh_visual); | 1256 serialize_visualinfo(bi, &uhp->uh_visual); |
1307 corruption_error("uh_seq", file_name); | 1301 corruption_error("uh_seq", file_name); |
1308 vim_free(uhp); | 1302 vim_free(uhp); |
1309 return NULL; | 1303 return NULL; |
1310 } | 1304 } |
1311 unserialize_pos(bi, &uhp->uh_cursor); | 1305 unserialize_pos(bi, &uhp->uh_cursor); |
1312 #ifdef FEAT_VIRTUALEDIT | |
1313 uhp->uh_cursor_vcol = undo_read_4c(bi); | 1306 uhp->uh_cursor_vcol = undo_read_4c(bi); |
1314 #else | |
1315 (void)undo_read_4c(bi); | |
1316 #endif | |
1317 uhp->uh_flags = undo_read_2c(bi); | 1307 uhp->uh_flags = undo_read_2c(bi); |
1318 for (i = 0; i < NMARKS; ++i) | 1308 for (i = 0; i < NMARKS; ++i) |
1319 unserialize_pos(bi, &uhp->uh_namedm[i]); | 1309 unserialize_pos(bi, &uhp->uh_namedm[i]); |
1320 unserialize_visualinfo(bi, &uhp->uh_visual); | 1310 unserialize_visualinfo(bi, &uhp->uh_visual); |
1321 uhp->uh_time = undo_read_time(bi); | 1311 uhp->uh_time = undo_read_time(bi); |
1456 static void | 1446 static void |
1457 serialize_pos(bufinfo_T *bi, pos_T pos) | 1447 serialize_pos(bufinfo_T *bi, pos_T pos) |
1458 { | 1448 { |
1459 undo_write_bytes(bi, (long_u)pos.lnum, 4); | 1449 undo_write_bytes(bi, (long_u)pos.lnum, 4); |
1460 undo_write_bytes(bi, (long_u)pos.col, 4); | 1450 undo_write_bytes(bi, (long_u)pos.col, 4); |
1461 #ifdef FEAT_VIRTUALEDIT | |
1462 undo_write_bytes(bi, (long_u)pos.coladd, 4); | 1451 undo_write_bytes(bi, (long_u)pos.coladd, 4); |
1463 #else | |
1464 undo_write_bytes(bi, (long_u)0, 4); | |
1465 #endif | |
1466 } | 1452 } |
1467 | 1453 |
1468 /* | 1454 /* |
1469 * Unserialize the pos_T at the current position. | 1455 * Unserialize the pos_T at the current position. |
1470 */ | 1456 */ |
1475 if (pos->lnum < 0) | 1461 if (pos->lnum < 0) |
1476 pos->lnum = 0; | 1462 pos->lnum = 0; |
1477 pos->col = undo_read_4c(bi); | 1463 pos->col = undo_read_4c(bi); |
1478 if (pos->col < 0) | 1464 if (pos->col < 0) |
1479 pos->col = 0; | 1465 pos->col = 0; |
1480 #ifdef FEAT_VIRTUALEDIT | |
1481 pos->coladd = undo_read_4c(bi); | 1466 pos->coladd = undo_read_4c(bi); |
1482 if (pos->coladd < 0) | 1467 if (pos->coladd < 0) |
1483 pos->coladd = 0; | 1468 pos->coladd = 0; |
1484 #else | |
1485 (void)undo_read_4c(bi); | |
1486 #endif | |
1487 } | 1469 } |
1488 | 1470 |
1489 /* | 1471 /* |
1490 * Serialize "info". | 1472 * Serialize "info". |
1491 */ | 1473 */ |
2853 if (curwin->w_cursor.lnum <= curbuf->b_ml.ml_line_count) | 2835 if (curwin->w_cursor.lnum <= curbuf->b_ml.ml_line_count) |
2854 { | 2836 { |
2855 if (curhead->uh_cursor.lnum == curwin->w_cursor.lnum) | 2837 if (curhead->uh_cursor.lnum == curwin->w_cursor.lnum) |
2856 { | 2838 { |
2857 curwin->w_cursor.col = curhead->uh_cursor.col; | 2839 curwin->w_cursor.col = curhead->uh_cursor.col; |
2858 #ifdef FEAT_VIRTUALEDIT | |
2859 if (virtual_active() && curhead->uh_cursor_vcol >= 0) | 2840 if (virtual_active() && curhead->uh_cursor_vcol >= 0) |
2860 coladvance((colnr_T)curhead->uh_cursor_vcol); | 2841 coladvance((colnr_T)curhead->uh_cursor_vcol); |
2861 else | 2842 else |
2862 curwin->w_cursor.coladd = 0; | 2843 curwin->w_cursor.coladd = 0; |
2863 #endif | |
2864 } | 2844 } |
2865 else | 2845 else |
2866 beginline(BL_SOL | BL_FIX); | 2846 beginline(BL_SOL | BL_FIX); |
2867 } | 2847 } |
2868 else | 2848 else |
2870 /* We get here with the current cursor line being past the end (eg | 2850 /* We get here with the current cursor line being past the end (eg |
2871 * after adding lines at the end of the file, and then undoing it). | 2851 * after adding lines at the end of the file, and then undoing it). |
2872 * check_cursor() will move the cursor to the last line. Move it to | 2852 * check_cursor() will move the cursor to the last line. Move it to |
2873 * the first column here. */ | 2853 * the first column here. */ |
2874 curwin->w_cursor.col = 0; | 2854 curwin->w_cursor.col = 0; |
2875 #ifdef FEAT_VIRTUALEDIT | |
2876 curwin->w_cursor.coladd = 0; | 2855 curwin->w_cursor.coladd = 0; |
2877 #endif | |
2878 } | 2856 } |
2879 | 2857 |
2880 /* Make sure the cursor is on an existing line and column. */ | 2858 /* Make sure the cursor is on an existing line and column. */ |
2881 check_cursor(); | 2859 check_cursor(); |
2882 | 2860 |