Mercurial > vim
comparison src/ops.c @ 1392:27782797c331 v7.1.107
updated for version 7.1-107
author | vimboss |
---|---|
date | Thu, 13 Sep 2007 20:41:32 +0000 |
parents | 33792c36e3aa |
children | 871231399cf5 |
comparison
equal
deleted
inserted
replaced
1391:c17ba3fb433e | 1392:27782797c331 |
---|---|
2475 { | 2475 { |
2476 struct block_def bd2; | 2476 struct block_def bd2; |
2477 | 2477 |
2478 /* | 2478 /* |
2479 * Spaces and tabs in the indent may have changed to other spaces and | 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 * Don't do this when "$" used, end-of-line will have changed. | 2481 * Don't do this when "$" used, end-of-line will have changed. |
2482 */ | 2482 */ |
2483 block_prep(oap, &bd2, oap->start.lnum, TRUE); | 2483 block_prep(oap, &bd2, oap->start.lnum, TRUE); |
2484 if (!bd.is_MAX || bd2.textlen < bd.textlen) | 2484 if (!bd.is_MAX || bd2.textlen < bd.textlen) |
2485 { | 2485 { |
2532 colnr_T l; | 2532 colnr_T l; |
2533 int retval; | 2533 int retval; |
2534 #ifdef FEAT_VISUALEXTRA | 2534 #ifdef FEAT_VISUALEXTRA |
2535 long offset; | 2535 long offset; |
2536 linenr_T linenr; | 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 char_u *firstline; | 2540 char_u *firstline; |
2539 char_u *ins_text, *newp, *oldp; | 2541 char_u *ins_text, *newp, *oldp; |
2540 struct block_def bd; | 2542 struct block_def bd; |
2541 #endif | 2543 #endif |
2542 | 2544 |
2577 /* Add spaces before getting the current line length. */ | 2579 /* Add spaces before getting the current line length. */ |
2578 if (virtual_op && (curwin->w_cursor.coladd > 0 | 2580 if (virtual_op && (curwin->w_cursor.coladd > 0 |
2579 || gchar_cursor() == NUL)) | 2581 || gchar_cursor() == NUL)) |
2580 coladvance_force(getviscol()); | 2582 coladvance_force(getviscol()); |
2581 # endif | 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 bd.textcol = curwin->w_cursor.col; | 2587 bd.textcol = curwin->w_cursor.col; |
2584 } | 2588 } |
2585 #endif | 2589 #endif |
2586 | 2590 |
2587 #if defined(FEAT_LISP) || defined(FEAT_CINDENT) | 2591 #if defined(FEAT_LISP) || defined(FEAT_CINDENT) |
2596 * In Visual block mode, handle copying the new text to all lines of the | 2600 * In Visual block mode, handle copying the new text to all lines of the |
2597 * block. | 2601 * block. |
2598 */ | 2602 */ |
2599 if (oap->block_mode && oap->start.lnum != oap->end.lnum) | 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 firstline = ml_get(oap->start.lnum); | 2607 firstline = ml_get(oap->start.lnum); |
2602 /* | 2608 if (bd.textcol > pre_indent) |
2603 * Subsequent calls to ml_get() flush the firstline data - take a | 2609 { |
2604 * copy of the required bit. | 2610 long new_indent = (long)(skipwhite(firstline) - firstline); |
2605 */ | 2611 |
2606 if ((ins_len = (long)STRLEN(firstline) - pre_textlen) > 0) | 2612 pre_textlen += new_indent - pre_indent; |
2607 { | 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 if ((ins_text = alloc_check((unsigned)(ins_len + 1))) != NULL) | 2621 if ((ins_text = alloc_check((unsigned)(ins_len + 1))) != NULL) |
2609 { | 2622 { |
2610 vim_strncpy(ins_text, firstline + bd.textcol, (size_t)ins_len); | 2623 vim_strncpy(ins_text, firstline + bd.textcol, (size_t)ins_len); |
2611 for (linenr = oap->start.lnum + 1; linenr <= oap->end.lnum; | 2624 for (linenr = oap->start.lnum + 1; linenr <= oap->end.lnum; |
2612 linenr++) | 2625 linenr++) |