From f2c03d7301d35590a20cc43431950acc3a2f6036 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 3 Feb 2015 18:36:44 +0100 Subject: updated for version 7.4.616 Problem: Cannot insert a tab in front of a block. Solution: Correctly compute aop->start. (Christian Brabandt) --- src/ops.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'src/ops.c') diff --git a/src/ops.c b/src/ops.c index a4261cb56..856133c8e 100644 --- a/src/ops.c +++ b/src/ops.c @@ -2544,6 +2544,7 @@ op_insert(oap, count1) char_u *firstline, *ins_text; struct block_def bd; int i; + pos_T t1; /* edit() changes this - record it for OP_APPEND */ bd.is_MAX = (curwin->w_curswant == MAXCOL); @@ -2617,8 +2618,16 @@ op_insert(oap, count1) } } + t1 = oap->start; edit(NUL, FALSE, (linenr_T)count1); + /* When a tab was inserted, and the characters in front of the tab + * have been converted to a tab as well, the column of the cursor + * might have actually been reduced, so need to adjust here. */ + if (t1.lnum == curbuf->b_op_start_orig.lnum + && lt(curbuf->b_op_start_orig, t1)) + oap->start = curbuf->b_op_start_orig; + /* If user has moved off this line, we don't know what to do, so do * nothing. * Also don't repeat the insert when Insert mode ended with CTRL-C. */ @@ -2644,10 +2653,11 @@ op_insert(oap, count1) #endif ) { + int t = getviscol2(curbuf->b_op_start_orig.col, + curbuf->b_op_start_orig.coladd); oap->start.col = curbuf->b_op_start_orig.col; - pre_textlen -= getviscol2(oap->start.col, oap->start.coladd) - - oap->start_vcol; - oap->start_vcol = getviscol2(oap->start.col, oap->start.coladd); + pre_textlen -= t - oap->start_vcol; + oap->start_vcol = t; } else if (oap->op_type == OP_APPEND && oap->end.col @@ -2660,12 +2670,13 @@ op_insert(oap, count1) #endif ) { + int t = getviscol2(curbuf->b_op_start_orig.col, + curbuf->b_op_start_orig.coladd); oap->start.col = curbuf->b_op_start_orig.col; /* reset pre_textlen to the value of OP_INSERT */ pre_textlen += bd.textlen; - pre_textlen -= getviscol2(oap->start.col, oap->start.coladd) - - oap->start_vcol; - oap->start_vcol = getviscol2(oap->start.col, oap->start.coladd); + pre_textlen -= t - oap->start_vcol; + oap->start_vcol = t; oap->op_type = OP_INSERT; } } -- cgit v1.2.1