Mirror of the Vim source from https://github.com/vim/vim
Revisão | 27782797c331b8800c12ad17c5d05adab5e92edb (tree) |
---|---|
Hora | 2007-09-14 05:41:32 |
Autor | vimboss |
Commiter | vimboss |
updated for version 7.1-107
@@ -2477,7 +2477,7 @@ | ||
2477 | 2477 | |
2478 | 2478 | /* |
2479 | 2479 | * Spaces and tabs in the indent may have changed to other spaces and |
2480 | - * tabs. Get the starting column again and correct the lenght. | |
2480 | + * tabs. Get the starting column again and correct the length. | |
2481 | 2481 | * Don't do this when "$" used, end-of-line will have changed. |
2482 | 2482 | */ |
2483 | 2483 | block_prep(oap, &bd2, oap->start.lnum, TRUE); |
@@ -2534,7 +2534,9 @@ | ||
2534 | 2534 | #ifdef FEAT_VISUALEXTRA |
2535 | 2535 | long offset; |
2536 | 2536 | linenr_T linenr; |
2537 | - long ins_len, pre_textlen = 0; | |
2537 | + long ins_len; | |
2538 | + long pre_textlen = 0; | |
2539 | + long pre_indent = 0; | |
2538 | 2540 | char_u *firstline; |
2539 | 2541 | char_u *ins_text, *newp, *oldp; |
2540 | 2542 | struct block_def bd; |
@@ -2579,7 +2581,9 @@ | ||
2579 | 2581 | || gchar_cursor() == NUL)) |
2580 | 2582 | coladvance_force(getviscol()); |
2581 | 2583 | # endif |
2582 | - pre_textlen = (long)STRLEN(ml_get(oap->start.lnum)); | |
2584 | + firstline = ml_get(oap->start.lnum); | |
2585 | + pre_textlen = (long)STRLEN(firstline); | |
2586 | + pre_indent = (long)(skipwhite(firstline) - firstline); | |
2583 | 2587 | bd.textcol = curwin->w_cursor.col; |
2584 | 2588 | } |
2585 | 2589 | #endif |
@@ -2598,13 +2602,22 @@ | ||
2598 | 2602 | */ |
2599 | 2603 | if (oap->block_mode && oap->start.lnum != oap->end.lnum) |
2600 | 2604 | { |
2605 | + /* Auto-indenting may have changed the indent. If the cursor was past | |
2606 | + * the indent, exclude that indent change from the inserted text. */ | |
2601 | 2607 | firstline = ml_get(oap->start.lnum); |
2602 | - /* | |
2603 | - * Subsequent calls to ml_get() flush the firstline data - take a | |
2604 | - * copy of the required bit. | |
2605 | - */ | |
2606 | - if ((ins_len = (long)STRLEN(firstline) - pre_textlen) > 0) | |
2608 | + if (bd.textcol > pre_indent) | |
2607 | 2609 | { |
2610 | + long new_indent = (long)(skipwhite(firstline) - firstline); | |
2611 | + | |
2612 | + pre_textlen += new_indent - pre_indent; | |
2613 | + bd.textcol += new_indent - pre_indent; | |
2614 | + } | |
2615 | + | |
2616 | + ins_len = (long)STRLEN(firstline) - pre_textlen; | |
2617 | + if (ins_len > 0) | |
2618 | + { | |
2619 | + /* Subsequent calls to ml_get() flush the firstline data - take a | |
2620 | + * copy of the inserted text. */ | |
2608 | 2621 | if ((ins_text = alloc_check((unsigned)(ins_len + 1))) != NULL) |
2609 | 2622 | { |
2610 | 2623 | vim_strncpy(ins_text, firstline + bd.textcol, (size_t)ins_len); |
@@ -667,6 +667,8 @@ | ||
667 | 667 | static int included_patches[] = |
668 | 668 | { /* Add new patch number below this line */ |
669 | 669 | /**/ |
670 | + 107, | |
671 | +/**/ | |
670 | 672 | 106, |
671 | 673 | /**/ |
672 | 674 | 105, |