Mercurial > vim
comparison src/ops.c @ 6579:a287b0e9e87b v7.4.616
updated for version 7.4.616
Problem: Cannot insert a tab in front of a block.
Solution: Correctly compute aop->start. (Christian Brabandt)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Tue, 03 Feb 2015 18:36:44 +0100 |
parents | c1ed973fb58f |
children | 399216850e36 |
comparison
equal
deleted
inserted
replaced
6578:86561ade8f81 | 6579:a287b0e9e87b |
---|---|
2542 { | 2542 { |
2543 long ins_len, pre_textlen = 0; | 2543 long ins_len, pre_textlen = 0; |
2544 char_u *firstline, *ins_text; | 2544 char_u *firstline, *ins_text; |
2545 struct block_def bd; | 2545 struct block_def bd; |
2546 int i; | 2546 int i; |
2547 pos_T t1; | |
2547 | 2548 |
2548 /* edit() changes this - record it for OP_APPEND */ | 2549 /* edit() changes this - record it for OP_APPEND */ |
2549 bd.is_MAX = (curwin->w_curswant == MAXCOL); | 2550 bd.is_MAX = (curwin->w_curswant == MAXCOL); |
2550 | 2551 |
2551 /* vis block is still marked. Get rid of it now. */ | 2552 /* vis block is still marked. Get rid of it now. */ |
2615 && oap->start_vcol != oap->end_vcol) | 2616 && oap->start_vcol != oap->end_vcol) |
2616 inc_cursor(); | 2617 inc_cursor(); |
2617 } | 2618 } |
2618 } | 2619 } |
2619 | 2620 |
2621 t1 = oap->start; | |
2620 edit(NUL, FALSE, (linenr_T)count1); | 2622 edit(NUL, FALSE, (linenr_T)count1); |
2623 | |
2624 /* When a tab was inserted, and the characters in front of the tab | |
2625 * have been converted to a tab as well, the column of the cursor | |
2626 * might have actually been reduced, so need to adjust here. */ | |
2627 if (t1.lnum == curbuf->b_op_start_orig.lnum | |
2628 && lt(curbuf->b_op_start_orig, t1)) | |
2629 oap->start = curbuf->b_op_start_orig; | |
2621 | 2630 |
2622 /* If user has moved off this line, we don't know what to do, so do | 2631 /* If user has moved off this line, we don't know what to do, so do |
2623 * nothing. | 2632 * nothing. |
2624 * Also don't repeat the insert when Insert mode ended with CTRL-C. */ | 2633 * Also don't repeat the insert when Insert mode ended with CTRL-C. */ |
2625 if (curwin->w_cursor.lnum != oap->start.lnum || got_int) | 2634 if (curwin->w_cursor.lnum != oap->start.lnum || got_int) |
2642 #ifdef FEAT_VIRTUALEDIT | 2651 #ifdef FEAT_VIRTUALEDIT |
2643 + curbuf->b_op_start_orig.coladd | 2652 + curbuf->b_op_start_orig.coladd |
2644 #endif | 2653 #endif |
2645 ) | 2654 ) |
2646 { | 2655 { |
2656 int t = getviscol2(curbuf->b_op_start_orig.col, | |
2657 curbuf->b_op_start_orig.coladd); | |
2647 oap->start.col = curbuf->b_op_start_orig.col; | 2658 oap->start.col = curbuf->b_op_start_orig.col; |
2648 pre_textlen -= getviscol2(oap->start.col, oap->start.coladd) | 2659 pre_textlen -= t - oap->start_vcol; |
2649 - oap->start_vcol; | 2660 oap->start_vcol = t; |
2650 oap->start_vcol = getviscol2(oap->start.col, oap->start.coladd); | |
2651 } | 2661 } |
2652 else if (oap->op_type == OP_APPEND | 2662 else if (oap->op_type == OP_APPEND |
2653 && oap->end.col | 2663 && oap->end.col |
2654 #ifdef FEAT_VIRTUALEDIT | 2664 #ifdef FEAT_VIRTUALEDIT |
2655 + oap->end.coladd | 2665 + oap->end.coladd |
2658 #ifdef FEAT_VIRTUALEDIT | 2668 #ifdef FEAT_VIRTUALEDIT |
2659 + curbuf->b_op_start_orig.coladd | 2669 + curbuf->b_op_start_orig.coladd |
2660 #endif | 2670 #endif |
2661 ) | 2671 ) |
2662 { | 2672 { |
2673 int t = getviscol2(curbuf->b_op_start_orig.col, | |
2674 curbuf->b_op_start_orig.coladd); | |
2663 oap->start.col = curbuf->b_op_start_orig.col; | 2675 oap->start.col = curbuf->b_op_start_orig.col; |
2664 /* reset pre_textlen to the value of OP_INSERT */ | 2676 /* reset pre_textlen to the value of OP_INSERT */ |
2665 pre_textlen += bd.textlen; | 2677 pre_textlen += bd.textlen; |
2666 pre_textlen -= getviscol2(oap->start.col, oap->start.coladd) | 2678 pre_textlen -= t - oap->start_vcol; |
2667 - oap->start_vcol; | 2679 oap->start_vcol = t; |
2668 oap->start_vcol = getviscol2(oap->start.col, oap->start.coladd); | |
2669 oap->op_type = OP_INSERT; | 2680 oap->op_type = OP_INSERT; |
2670 } | 2681 } |
2671 } | 2682 } |
2672 | 2683 |
2673 /* | 2684 /* |